From c94c4a6c9511a677147d6492e9ec36ff64622925 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sun, 20 Aug 2023 12:14:08 -0700 Subject: [PATCH] Teach resources/page_css how to load CSS stylesheets with .Kind --- layouts/partials/resources/page_css.html | 26 +++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/layouts/partials/resources/page_css.html b/layouts/partials/resources/page_css.html index 6bd5f43..6bbd568 100644 --- a/layouts/partials/resources/page_css.html +++ b/layouts/partials/resources/page_css.html @@ -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 }}