diff --git a/layouts/partials/dark.css b/assets/css/dark.css similarity index 96% rename from layouts/partials/dark.css rename to assets/css/dark.css index cd60154..d32fd15 100644 --- a/layouts/partials/dark.css +++ b/assets/css/dark.css @@ -1,3 +1,4 @@ +/* dark.css */ --font-color: #eee; --bg-color: #212121; diff --git a/static/css/light.css b/assets/css/light.css similarity index 95% rename from static/css/light.css rename to assets/css/light.css index 19ba085..34aa6e3 100644 --- a/static/css/light.css +++ b/assets/css/light.css @@ -1,4 +1,5 @@ :root { + /* light.css */ --font-color: #333; --bg-color: #fff; @@ -11,7 +12,7 @@ --pre-color: #333; --pre-bg-color: #f1f1f1; - + --bq-color: #ccc; --hr-color: #ccc; diff --git a/static/css/style.css b/assets/css/main.css similarity index 94% rename from static/css/style.css rename to assets/css/main.css index 9bd6a5a..ee6aca0 100644 --- a/static/css/style.css +++ b/assets/css/main.css @@ -1,3 +1,24 @@ +{{ $light := resources.Get "css/light.css" }} +{{ $dark := resources.Get "css/dark.css" }} + +{{ $light.Content }} + +{{ if eq site.Params.style "dark-without-switcher" }} +:root { + {{ $dark.Content }} +} +{{ else if eq site.Params.style "auto-without-switcher" }} +@media (prefers-color-scheme: dark) { + :root { + {{ $dark.Content }} + } +} +{{else }} +[data-theme="dark"] { + {{ $dark.Content }} +} +{{ end }} + /* Basic */ html { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; @@ -123,7 +144,7 @@ th, td { /* Code */ pre { - color: var(--pre-color) + color: var(--pre-color); background-color: var(--pre-bg-color); padding: 1em; max-width: 100%; diff --git a/layouts/partials/cssColors.html b/layouts/partials/cssColors.html deleted file mode 100644 index 3f64049..0000000 --- a/layouts/partials/cssColors.html +++ /dev/null @@ -1,18 +0,0 @@ - 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 @@ - -{{ partial "cssColors.html" }} - +{{ $cssTemplate := resources.Get "css/main.css" }} +{{ $style := $cssTemplate | resources.ExecuteAsTemplate "css/style.css" . | resources.ToCSS | resources.Fingerprint "sha256" }} + {{ range .Site.Params.customCSS -}} @@ -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" . }}