mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
variant: add referenced but not configured variants #679
This commit is contained in:
parent
1119b3f9a6
commit
87df35a9f9
1 changed files with 18 additions and 4 deletions
|
@ -3,11 +3,12 @@
|
|||
{{- $printres := resources.Get "css/format-print.css" }}
|
||||
|
||||
{{- /*
|
||||
First run:
|
||||
Config run:
|
||||
- convert from old forms to slice of dicts
|
||||
- convert auto property to slice
|
||||
- add name property
|
||||
*/}}
|
||||
{{- $refthemevariants := slice | append "relearn-light" | append "relearn-dark" }}
|
||||
{{- $tempthemevariants := slice | append (.Site.Params.themeVariant | default "auto" ) }}
|
||||
{{- $themevariants := slice }}
|
||||
{{- range $tempthemevariant := $tempthemevariants }}
|
||||
|
@ -20,12 +21,25 @@ First run:
|
|||
{{- end }}
|
||||
{{- if eq $themevariant.identifier "auto" }}
|
||||
{{- $themevariant = collections.Merge $themevariant (dict "auto" ($themevariant.auto | default slice)) }}
|
||||
{{- $refthemevariants = $refthemevariants | append $themevariant.auto }}
|
||||
{{- end }}
|
||||
{{- $themevariant = collections.Merge $themevariant (dict "config" true) }}
|
||||
{{- $themevariants = $themevariants | append $themevariant }}
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
Second run, handle non-auto variants
|
||||
Ref run:
|
||||
- add non-configured but referenced variants
|
||||
*/}}
|
||||
{{- range $refthemevariant := $refthemevariants }}
|
||||
{{- if not (index (collections.Where $themevariants "identifier" $refthemevariant) 0) }}
|
||||
{{- $themevariant := (dict "identifier" $refthemevariant "name" ($refthemevariant | humanize | strings.Title) "config" false) }}
|
||||
{{- $themevariants = $themevariants | append $themevariant }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
Non-auto run
|
||||
- fix and regenerate theme css for advanced config mode
|
||||
- add chroma property from stylesheet
|
||||
*/}}
|
||||
|
@ -61,7 +75,7 @@ Second run, handle non-auto variants
|
|||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
Third run, handle auto variants
|
||||
Auto run
|
||||
- fill up auto property
|
||||
- fill up chroma property
|
||||
- generate theme and chroma css files from template
|
||||
|
@ -113,4 +127,4 @@ Third run, handle auto variants
|
|||
{{- $cssres := $printres | resources.ExecuteAsTemplate "css/format-print.css" (index (collections.Where $themevariants "identifier" "relearn-light") 0) }}
|
||||
{{- /* the following code causes Hugo to generate our css file - although it is in comments */}}<!-- {{ $cssres.RelPermalink }} -->
|
||||
|
||||
{{- return $themevariants }}
|
||||
{{- return collections.Where $tempthemevariants "config" true }}
|
Loading…
Reference in a new issue