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.
This commit is contained in:
Quentin Barbe 2020-10-23 13:48:07 +02:00
parent 9e524ff754
commit db7e6254fa
No known key found for this signature in database
GPG key ID: C479C6EF498510C2
5 changed files with 29 additions and 24 deletions

View file

@ -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" . }}
{{ partial "head-extra.html" . }}