diff options
author | Quentin Barbe <quentin@barbe.me> | 2020-10-23 14:48:07 +0300 |
---|---|---|
committer | Quentin Barbe <quentin@barbe.me> | 2020-10-23 14:58:37 +0300 |
commit | db7e6254fa6105ae477a9b0bc3ee268d0e20fd17 (patch) | |
tree | 177154659138229bb60b6f9baa92a6fc4e1c73b3 /layouts/partials/head.html | |
parent | 9e524ff754b0abfb2887f448a52c2c2cf3bc6f47 (diff) |
Merge style sheets for light and dark themes into a single resource
This will avoid having inline style, which is annoying for stricter CSP.
It should improve performances, as there is only a single file to load.
As a bonus, I also included resource fingerprinting, which will avoid breaking
the cache when it's not needed, and adds subresource integrity checksum.
Diffstat (limited to 'layouts/partials/head.html')
-rw-r--r-- | layouts/partials/head.html | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/layouts/partials/head.html b/layouts/partials/head.html index a1d5e47..48b6ebd 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -14,9 +14,9 @@ <link rel="icon" type="image/x-icon" href="{{ "favicon.ico" | absURL }}"> <link rel="apple-touch-icon-precomposed" href="{{ "favicon.png" | absURL }}"> -<link rel="stylesheet" href="{{ "css/light.css" | absURL }}?rnd={{ now.Unix }}" /> -{{ partial "cssColors.html" }} -<link rel="stylesheet" href="{{ "css/style.css" | absURL }}?rnd={{ now.Unix }}" /> +{{ $cssTemplate := resources.Get "css/main.css" }} +{{ $style := $cssTemplate | resources.ExecuteAsTemplate "css/style.css" . | resources.ToCSS | resources.Fingerprint "sha256" }} +<link rel="stylesheet" href="{{ $style.Permalink }}" integrity="{{ $style.Data.Integrity }}"> {{ range .Site.Params.customCSS -}} <link rel="stylesheet" href="{{ . | absURL }}?rnd={{ now.Unix }}"> @@ -39,4 +39,4 @@ {{ template "_internal/google_analytics_async.html" . }} {{ end }} -{{ partial "head-extra.html" . }}
\ No newline at end of file +{{ partial "head-extra.html" . }} |