From ee9856628378cbf2fc9b79cb63171fb7212e720e Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Mon, 20 Nov 2023 11:55:40 -0800 Subject: [PATCH] In the page_css partial, check array length and presence of $.File before concatenating stylesheets --- layouts/partials/resources/page_css.html | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/layouts/partials/resources/page_css.html b/layouts/partials/resources/page_css.html index 6bbd568..90adbea 100644 --- a/layouts/partials/resources/page_css.html +++ b/layouts/partials/resources/page_css.html @@ -15,10 +15,22 @@ {{ 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") }} + {{/* + Replace the list of stylesheets that helps with debugging with a + concatenated and fingerprinted version. + */}} + {{ if gt (len $processedStylesheets) 0 }} + {{ with $file := $.File }} + {{ $outputFilename := printf "%s/page.css" $.File.Dir }} + {{ $processedStylesheets = slice ($processedStylesheets + | resources.Concat $outputFilename + | fingerprint "md5") }} + {{ else }} + {{ warnf "No File for page CSS." }} + {{ end }} + {{ end }} {{ end }} {{ return $processedStylesheets }}