Teach resources/page_css how to load CSS stylesheets with .Kind

This commit is contained in:
Eryn Wells 2023-08-20 12:14:08 -07:00
parent 851c74b2c9
commit c94c4a6c95

View file

@ -1,12 +1,24 @@
{{ $stylesheets := slice }}
{{ with .Resources.Match "*.css" }}
{{ range . }}
{{ $stylesheets = $stylesheets | append (. | resources.ExecuteAsTemplate .Name .) }}
{{ end }}
{{ if hugo.IsProduction }}
{{ $stylesheets = slice ($stylesheets
| resources.Concat (printf "%s/page.css" $.File.Dir)
| fingerprint "md5") }}
{{ $stylesheets = $stylesheets | append . }}
{{ end }}
{{ end }}
{{ return $stylesheets }}
{{ if eq .Kind "home" }}
{{ with resources.Get "styles/home.css" }}
{{ $stylesheets = $stylesheets | append . }}
{{ end }}
{{ end }}
{{ $processedStylesheets := slice }}
{{ range $stylesheets }}
{{ $processedStylesheets = $processedStylesheets | append (. | resources.ExecuteAsTemplate .Name .) }}
{{ end }}
{{ if hugo.IsProduction }}
{{ $processedStylesheets = slice ($processedStylesheets
| resources.Concat (printf "%s/page.css" $.File.Dir)
| fingerprint "md5") }}
{{ end }}
{{ return $processedStylesheets }}