From c90d41e5c1d96fe9117d70b993634f646e6f0244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Wed, 3 Jul 2024 22:03:44 +0200 Subject: [PATCH] variant: auto variant references potentially wrong chroma style #873 --- layouts/partials/get-theme-variants.hugo | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/layouts/partials/get-theme-variants.hugo b/layouts/partials/get-theme-variants.hugo index e489e151af..673ae7afa7 100644 --- a/layouts/partials/get-theme-variants.hugo +++ b/layouts/partials/get-theme-variants.hugo @@ -39,7 +39,6 @@ Auto run: - save variants referenced by auto configuration - write variant CSS file based on auto template - add chroma property -- write chroma CSS file based on auto template */}} {{- $defaultautothemevariants := slice }} {{- $defaultautothemevariants = $defaultautothemevariants | append (index .Site.Params.themeVariantAuto 0 | default (index $nonautothemevariants 0) | default "relearn-light") }} @@ -56,8 +55,6 @@ Auto run: {{- $cssres := $autores | resources.ExecuteAsTemplate (printf "css/theme-%s.css" $themevariant.identifier) (dict "prefix" "theme" "light" $light "dark" $dark) }} {{- /* the following code causes Hugo to generate our css file - although it is in comments */}} {{- $themevariant = collections.Merge $themevariant (dict "chroma" $themevariant.identifier) }} - {{- $cssres = $autores | resources.ExecuteAsTemplate (printf "css/chroma-%s.css" $themevariant.chroma) (dict "prefix" "chroma" "light" $light "dark" $dark) }} - {{- /* the following code causes Hugo to generate our css file - although it is in comments */}} {{- end }} {{- $themevariants = $themevariants | append $themevariant }} {{- end }} @@ -95,6 +92,22 @@ Non-auto run: {{- $themevariants = $themevariants | append $themevariant }} {{- end }} +{{- /* +Chroma auto run: +- write chroma CSS file based on auto template +*/}} +{{- range $tempthemevariant := $themevariants }} + {{- $themevariant := $tempthemevariant }} + {{- if collections.IsSet $themevariant "auto" }} + {{- $lighttheme := index $themevariant.auto 0 | default (index $defaultautothemevariants 0) }} + {{- $darktheme := index $themevariant.auto 1 | default (index $defaultautothemevariants 1) }} + {{- $light := (index (collections.Where $themevariants "identifier" $lighttheme) 0).chroma }} + {{- $dark := (index (collections.Where $themevariants "identifier" $darktheme) 0).chroma }} + {{- $cssres := $autores | resources.ExecuteAsTemplate (printf "css/chroma-%s.css" $themevariant.chroma) (dict "prefix" "chroma" "light" $light "dark" $dark) }} + {{- /* the following code causes Hugo to generate our css file - although it is in comments */}} + {{- end }} +{{- end }} + {{- $cssres := $printres | resources.ExecuteAsTemplate "css/format-print.css" (dict "themevariant" (index (collections.Where $themevariants "identifier" "relearn-light") 0)) }} {{- /* the following code causes Hugo to generate our css file - although it is in comments */}}