From 44e8c677a6ab1b291e27b104d6bf9e66e0c42fd1 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Thu, 23 Jan 2020 19:34:21 +0200 Subject: [PATCH] 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 --- {static => assets}/css/cookieconsent.min.css | 0 {static => assets}/css/style.css | 0 {static => assets}/css/style.rtl.css | 0 {static => assets}/js/cookieconsent.min.js | 0 layouts/_default/baseof.html | 6 ++++-- layouts/partials/cookie-consent.html | 6 ++++-- package.json | 8 ++++---- 7 files changed, 12 insertions(+), 8 deletions(-) rename {static => assets}/css/cookieconsent.min.css (100%) rename {static => assets}/css/style.css (100%) rename {static => assets}/css/style.rtl.css (100%) rename {static => assets}/js/cookieconsent.min.js (100%) diff --git a/static/css/cookieconsent.min.css b/assets/css/cookieconsent.min.css similarity index 100% rename from static/css/cookieconsent.min.css rename to assets/css/cookieconsent.min.css diff --git a/static/css/style.css b/assets/css/style.css similarity index 100% rename from static/css/style.css rename to assets/css/style.css diff --git a/static/css/style.rtl.css b/assets/css/style.rtl.css similarity index 100% rename from static/css/style.rtl.css rename to assets/css/style.rtl.css diff --git a/static/js/cookieconsent.min.js b/assets/js/cookieconsent.min.js similarity index 100% rename from static/js/cookieconsent.min.js rename to assets/js/cookieconsent.min.js diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 04ba23d..e0ca337 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -14,10 +14,12 @@ {{ if or (eq .Lang "ar") (eq .Lang "fa") }} {{ "" | safeHTML }} - + {{ $styleRtl := resources.Get "css/style.rtl.css" | resources.Fingerprint }} + {{ else }} {{ "" | safeHTML }} - + {{ $style := resources.Get "css/style.css" | resources.Fingerprint }} + {{ end }} {{ "" | safeHTML }} diff --git a/layouts/partials/cookie-consent.html b/layouts/partials/cookie-consent.html index 24d5689..e0e72a4 100644 --- a/layouts/partials/cookie-consent.html +++ b/layouts/partials/cookie-consent.html @@ -1,5 +1,7 @@ - - +{{ $cookieConsentStyle := resources.Get "css/cookieconsent.min.css" | resources.Fingerprint }} + +{{ $cookieConsentScript := resources.Get "js/cookieconsent.min.js" | resources.Fingerprint }} +