variant: restructuring #679

This commit is contained in:
Sören Weber 2023-12-03 18:31:44 +01:00
parent 3dc2f9a629
commit ce464fe11a
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -49,8 +49,9 @@ Non-auto run
{{- range $tempthemevariant := $tempthemevariants }} {{- range $tempthemevariant := $tempthemevariants }}
{{- $themevariant := $tempthemevariant }} {{- $themevariant := $tempthemevariant }}
{{- if not (collections.IsSet $themevariant "auto") }} {{- if not (collections.IsSet $themevariant "auto") }}
{{- $chroma := partial "get-theme-chroma.html" (dict "identifier" $themevariant.identifier "mod" $mod)}} {{- $themevariant = partial "get-theme-details.html" (dict "themevariant" $themevariant "identifier" $themevariant.identifier "mod" $mod)}}
{{- $themevariant = collections.Merge $themevariant (dict "chroma" $chroma) }} {{- $cssres := $themevariant.themecontent | resources.FromString (printf "css/theme-%s%s.css" $themevariant.identifier $mod) }}
{{- /* the following code causes Hugo to generate our css file - although it is in comments */}}<!-- {{ $cssres.RelPermalink }} -->
{{- end }} {{- end }}
{{- $themevariants = $themevariants | append $themevariant }} {{- $themevariants = $themevariants | append $themevariant }}
{{- end }} {{- end }}
@ -110,7 +111,8 @@ Auto run
{{- return collections.Where $themevariants "config" true }} {{- return collections.Where $themevariants "config" true }}
{{ define "partials/get-theme-chroma.html" }} {{ define "partials/get-theme-details.html" }}
{{- $themevariant := .themevariant }}
{{- $identifier := .identifier }} {{- $identifier := .identifier }}
{{- $mod := .mod }} {{- $mod := .mod }}
{{- $themecontent := "" }} {{- $themecontent := "" }}
@ -135,14 +137,15 @@ Auto run
{{- else }} {{- else }}
{{- range findRESubmatch (printf `[ \t]*@import\s+[^$]*?theme-([^.]*?)%s\.css` (replace $mod "." "\\.")) $themecontent }} {{- range findRESubmatch (printf `[ \t]*@import\s+[^$]*?theme-([^.]*?)%s\.css` (replace $mod "." "\\.")) $themecontent }}
{{- $subidentifier := index . 1 }} {{- $subidentifier := index . 1 }}
{{- $chroma = partial "get-theme-chroma.html" (dict "identifier" $subidentifier "mod" $mod) }} {{- $themevariant = partial "get-theme-details.html" (dict "themevariant" $themevariant "identifier" $subidentifier "mod" $mod) }}
{{- $chroma = $themevariant.chroma }}
{{- else }} {{- else }}
{{- $chroma = "relearn-light" }} {{- $chroma = "relearn-light" }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- $themecontent = replaceRE `(:root\s*\{[ \t]*)(\s*)` (printf "${1}${2}--CODE-theme: %s;${2}" $chroma) $themecontent }} {{- $themecontent = replaceRE `(:root\s*\{[ \t]*)(\s*)` (printf "${1}${2}--CODE-theme: %s;${2}" $chroma) $themecontent }}
{{- end }} {{- end }}
{{- $cssres := $themecontent | resources.FromString (printf "css/theme-%s%s.css" $identifier $mod) }} {{- $themevariant = collections.Merge $themevariant (dict "themecontent" $themecontent) }}
{{- /* the following code causes Hugo to generate our css file - although it is in comments */}}<!-- {{ $cssres.RelPermalink }} --> {{- $themevariant = collections.Merge $themevariant (dict "chroma" $chroma) }}
{{- return $chroma }} {{- return $themevariant }}
{{- end }} {{- end }}