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:
parent
9e524ff754
commit
db7e6254fa
5 changed files with 29 additions and 24 deletions
|
@ -1,18 +0,0 @@
|
|||
<style>
|
||||
{{ if eq site.Params.style "dark-without-switcher" }}
|
||||
:root {
|
||||
{{ partial "dark.css" . | safeCSS }}
|
||||
}
|
||||
{{ else if eq site.Params.style "auto-without-switcher" }}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
{{ partial "dark.css" . | safeCSS }}
|
||||
}
|
||||
|
||||
}
|
||||
{{else }}
|
||||
[data-theme="dark"] {
|
||||
{{ partial "dark.css" . | safeCSS }}
|
||||
}
|
||||
{{ end }}
|
||||
</style>
|
|
@ -1,23 +0,0 @@
|
|||
--font-color: #eee;
|
||||
--bg-color: #212121;
|
||||
|
||||
--link-color:#599ada;
|
||||
--link-state-color:#ff5858;
|
||||
--link-state-border-color: rgba(238, 54, 54, 0.5);
|
||||
|
||||
--thead-bg-color: #343a40;
|
||||
--table-border-color: lightgrey;
|
||||
|
||||
--pre-color: #333;
|
||||
--pre-bg-color: #f1f1f1;
|
||||
|
||||
--bq-color: #ccc;
|
||||
--hr-color: #333;
|
||||
|
||||
--pagination-bg-color: #373737;
|
||||
--pagination-link-color: #b6b6b6;
|
||||
|
||||
--post-info-color: grey;
|
||||
|
||||
--switcher-color: #333;
|
||||
--switcher-bg-color: #fff;
|
|
@ -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" . }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue