mirror of
https://github.com/alanorth/hugo-theme-bootstrap4-blog.git
synced 2024-12-25 03:34:29 +01:00
Use Hugo's built-in subresource integrity support
We can use Hugo's built-in SRI support instead of using our custom SRI generator script (as cool as it was at the time). This is more clean and gives us the added benefit of adding fingerprints to the CSS and JS filenames, which acts as a cache buster. See: https://gohugo.io/hugo-pipes/introduction/ See: https://github.com/alanorth/hugo-theme-bootstrap4-blog/issues/120
This commit is contained in:
parent
6e36b66fab
commit
44e8c677a6
@ -14,10 +14,12 @@
|
||||
|
||||
{{ if or (eq .Lang "ar") (eq .Lang "fa") }}
|
||||
{{ "<!-- ar -->" | safeHTML }}
|
||||
<link href="{{ "css/style.rtl.css" | absURL }}" rel="stylesheet"{{ if not .Site.Params.disable_sri }} integrity="{{ .Site.Data.sri.styleltr}}" crossorigin="anonymous"{{ end }}>
|
||||
{{ $styleRtl := resources.Get "css/style.rtl.css" | resources.Fingerprint }}
|
||||
<link href="{{ $styleRtl.Permalink }}" rel="stylesheet"{{ if not .Site.Params.disable_sri }} integrity="{{ $styleRtl.Data.Integrity }}" crossorigin="anonymous"{{ end }}>
|
||||
{{ else }}
|
||||
{{ "<!-- combined, minified CSS -->" | safeHTML }}
|
||||
<link href="{{ "css/style.css" | absURL }}" rel="stylesheet"{{ if not .Site.Params.disable_sri }} integrity="{{ .Site.Data.sri.style}}" crossorigin="anonymous"{{ end }}>
|
||||
{{ $style := resources.Get "css/style.css" | resources.Fingerprint }}
|
||||
<link href="{{ $style.Permalink }}" rel="stylesheet"{{ if not .Site.Params.disable_sri }} integrity="{{ $style.Data.Integrity }}" crossorigin="anonymous"{{ end }}>
|
||||
{{ end }}
|
||||
|
||||
{{ "<!-- RSS 2.0 feed -->" | safeHTML }}
|
||||
|
@ -1,5 +1,7 @@
|
||||
<link href="{{ "css/cookieconsent.min.css" | absURL }}" rel="stylesheet" type="text/css"{{ if not .Site.Params.disable_sri }} integrity="{{ .Site.Data.sri.cookieconsentcss }}" crossorigin="anonymous"{{ end }}>
|
||||
<script src="{{ "js/cookieconsent.min.js" |absURL }}"{{ if not .Site.Params.disable_sri }} integrity="{{ .Site.Data.sri.cookieconsentjs }}" crossorigin="anonymous"{{ end }} async></script>
|
||||
{{ $cookieConsentStyle := resources.Get "css/cookieconsent.min.css" | resources.Fingerprint }}
|
||||
<link href="{{ $cookieConsentStyle.Permalink }}" rel="stylesheet" type="text/css"{{ if not .Site.Params.disable_sri }} integrity="{{ $cookieConsentStyle.Data.Integrity }}" crossorigin="anonymous"{{ end }}>
|
||||
{{ $cookieConsentScript := resources.Get "js/cookieconsent.min.js" | resources.Fingerprint }}
|
||||
<script src="{{ $cookieConsentScript.Permalink }}"{{ if not .Site.Params.disable_sri }} integrity="{{ $cookieConsentScript.Data.Integrity }}" crossorigin="anonymous"{{ end }} async></script>
|
||||
|
||||
<script>
|
||||
window.addEventListener("load", function(){
|
||||
|
@ -7,13 +7,13 @@
|
||||
"url": "https://github.com/alanorth/hugo-theme-bootstrap4-blog.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build:css": "node-sass --output-style expanded --precision 6 source/scss/style.scss static/css/style.css.tmp && cleancss --level 1 static/css/style.css.tmp -o static/css/style.css",
|
||||
"build:ltrcss": "rtlcss -s static/css/style.css.tmp static/css/style.rtl.css.tmp && cleancss --level 1 static/css/style.rtl.css.tmp -o static/css/style.rtl.css",
|
||||
"build:css": "node-sass --output-style expanded --precision 6 source/scss/style.scss assets/css/style.css.tmp && cleancss --level 1 assets/css/style.css.tmp -o assets/css/style.css",
|
||||
"build:ltrcss": "rtlcss -s assets/css/style.css.tmp assets/css/style.rtl.css.tmp && cleancss --level 1 assets/css/style.rtl.css.tmp -o assets/css/style.rtl.css",
|
||||
"build:fonts": "cp node_modules/font-awesome/fonts/* static/fonts",
|
||||
"build:cookieconsent": "cp node_modules/cookieconsent/build/cookieconsent.min.css static/css && cp node_modules/cookieconsent/build/cookieconsent.min.js static/js",
|
||||
"build:cookieconsent": "cp node_modules/cookieconsent/build/cookieconsent.min.css assets/css && cp node_modules/cookieconsent/build/cookieconsent.min.js assets/js",
|
||||
"build:generatesri": "node build/sri.js > data/sri.toml",
|
||||
"build": "npm run build:css && npm run build:ltrcss && npm run build:fonts && npm run build:cookieconsent && npm run build:generatesri && npm run clean",
|
||||
"clean": "rm static/css/style.css.tmp static/css/style.rtl.css.tmp"
|
||||
"clean": "rm assets/css/style.css.tmp assets/css/style.rtl.css.tmp"
|
||||
},
|
||||
"keywords": "hugo",
|
||||
"author": "Alan Orth",
|
||||
|
Loading…
Reference in New Issue
Block a user