From 2b11b7e9fbf56a9f2070e7d9e8a7a0320f76f014 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Sat, 1 Jun 2024 19:27:12 +0100 Subject: [PATCH] feat(tailwind): prevent error when using `hugo new site` As unfortunately Hugo always triggers error even when using `with` statement with a non-safelisted `os.Getenv` var --- modules/blox-tailwind/hugo.yaml | 5 +++-- modules/blox-tailwind/layouts/partials/init.html | 2 +- modules/blox-tailwind/layouts/partials/landing_page.html | 2 +- modules/blox-tailwind/layouts/partials/site_head.html | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/blox-tailwind/hugo.yaml b/modules/blox-tailwind/hugo.yaml index bc62377f..00a0ed16 100644 --- a/modules/blox-tailwind/hugo.yaml +++ b/modules/blox-tailwind/hugo.yaml @@ -80,9 +80,10 @@ module: security: funcs: getenv: + # Allow HUGO_ and HUGO_BLOX_ vars - ^HUGO_ - - ^WC_ - - ^HB_ + # Allow continuous integration vars + - ^CI$ outputFormats: backlinks: mediaType: application/json diff --git a/modules/blox-tailwind/layouts/partials/init.html b/modules/blox-tailwind/layouts/partials/init.html index f5b8467f..9eb5e760 100644 --- a/modules/blox-tailwind/layouts/partials/init.html +++ b/modules/blox-tailwind/layouts/partials/init.html @@ -6,7 +6,7 @@ {{ if eq .Type "landing" }} {{ range $index, $block := .Params.sections }} {{/* Do not show sections intended only for the demo site. */}} - {{ if or (not $block.demo) ($block.demo | and (eq (os.Getenv "WC_DEMO") "true")) }} + {{ if or (not $block.demo) ($block.demo | and (eq (os.Getenv "HUGO_BLOX_DEMO") "true")) }} {{ $block_type := lower ($block.blox | default $block.block) | default "markdown" }} {{ range $r := site.Data.blox_aliases.renames }} {{ $block_type = cond (eq $block_type $r.old) $r.new $block_type }} diff --git a/modules/blox-tailwind/layouts/partials/landing_page.html b/modules/blox-tailwind/layouts/partials/landing_page.html index c194ffa7..65e7cfc7 100644 --- a/modules/blox-tailwind/layouts/partials/landing_page.html +++ b/modules/blox-tailwind/layouts/partials/landing_page.html @@ -1,7 +1,7 @@ {{/* Load Hugo Blox */}} {{ range $index, $block := .Params.sections }} {{/* Do not show sections intended only for the demo site. */}} - {{ if or (not $block.demo) ($block.demo | and (eq (os.Getenv "WC_DEMO") "true")) }} + {{ if or (not $block.demo) ($block.demo | and (eq (os.Getenv "HUGO_BLOX_DEMO") "true")) }} {{ partial "functions/parse_block_v2" (dict "page" $ "block" $block) }} {{ end }} {{ end }} diff --git a/modules/blox-tailwind/layouts/partials/site_head.html b/modules/blox-tailwind/layouts/partials/site_head.html index dcf63aa1..0654a3fc 100644 --- a/modules/blox-tailwind/layouts/partials/site_head.html +++ b/modules/blox-tailwind/layouts/partials/site_head.html @@ -56,7 +56,7 @@ {{ end }} {{/* Style */}} - {{ if ne (os.Getenv "WC_POSTCSS") "true" }} + {{ if ne (os.Getenv "HUGO_BLOX_POSTCSS") "true" }} {{ $styles := resources.Get "dist/wc.min.css" }} {{ else }}