Skip to content

Commit d1da39b

Browse files
tony-hodaattali
authored andcommitted
Add Subresource Integrity (SRI) support (daattali#164)
1 parent 09e037d commit d1da39b

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ social-share | If you don't want to show buttons to share a blog post on social
143143
use-site-title | If you want to use the site title rather than page title as HTML document title (ie. browser tab title), use `use-site-title: true`. When set, the document title will take the format `Site Title - Site Description` (eg. `My website - A virtual proof that name is awesome!`). By default, it will use `Page Title` if it exists, or `Site Title` otherwise.
144144
layout | What type of page this is (default is `blog` for blog posts and `page` for other pages. You can use `minimal` if you don't want a header and footer)
145145
js | List of local JavaScript files to include in the page (eg. `/js/mypage.js`)
146-
ext-js | List of external JavaScript files to include in the page (eg. `//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js`)
146+
ext-js | List of external JavaScript files to include in the page (eg. `//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js`). External JavaScript files that support [Subresource Integrity (SRI)](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) can be specified using the `href` and `sri` parameters eg.<br/>`href: "//code.jquery.com/jquery-3.1.1.min.js"`<br/>`sri: "sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="`
147147
css | List of local CSS files to include in the page
148-
ex-css | List of external CSS files to include in the page
148+
ext-css | List of external CSS files to include in the page. External CSS files using SRI (see `ext-js` parameter) are also supported.
149149
googlefonts | List of Google fonts to include in the page (eg. `["Monoton", "Lobster"]`)
150150

151151
### Advanced features (including how to use a custom URL address for your site)

_includes/ext-css.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{% if include.css.sri %}
2+
<link href="{{ include.css.href }}" rel="stylesheet" integrity="{{ include.css.sri }}" crossorigin="anonymous">
3+
{% elsif include.css.href %}
4+
<link rel="stylesheet" href="{{ include.css.href }}" />
5+
{% else %}
6+
<link rel="stylesheet" href="{{ include.css }}" />
7+
{% endif %}

_includes/ext-js.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{% if include.js.sri %}
2+
<script src="{{ include.js.href }}" integrity="{{ include.js.sri }}" crossorigin="anonymous"></script>
3+
{% elsif include.js.href %}
4+
<script src="{{ include.js.href }}"></script>
5+
{% else %}
6+
<script src="{{ include.js }}"></script>
7+
{% endif %}

_includes/footer-scripts.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{% if layout.common-ext-js %}
22
{% for js in layout.common-ext-js %}
3-
<script src="{{ js }}"></script>
3+
{% include ext-js.html js=js %}
44
{% endfor %}
55
{% endif %}
66

77
{% if page.ext-js %}
88
{% for js in page.ext-js %}
9-
<script src="{{ js }}"></script>
9+
{% include ext-js.html js=js %}
1010
{% endfor %}
1111
{% endif %}
1212

_includes/head.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
{% if layout.common-ext-css %}
1919
{% for css in layout.common-ext-css %}
20-
<link rel="stylesheet" href="{{ css }}" />
20+
{% include ext-css.html css=css %}
2121
{% endfor %}
2222
{% endif %}
2323

@@ -35,7 +35,7 @@
3535

3636
{% if page.ext-css %}
3737
{% for css in page.ext-css %}
38-
<link rel="stylesheet" href="{{ css }}" />
38+
{% include ext-css.html css=css %}
3939
{% endfor %}
4040
{% endif %}
4141

0 commit comments

Comments
 (0)