Skip to content

Commit

Permalink
feat(tailwind): prevent error when using hugo new site
Browse files Browse the repository at this point in the history
As unfortunately Hugo always triggers error even when using `with` statement with a non-safelisted `os.Getenv` var
  • Loading branch information
gcushen committed Jun 1, 2024
1 parent 6b70757 commit 2b11b7e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions modules/blox-tailwind/hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/blox-tailwind/layouts/partials/init.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion modules/blox-tailwind/layouts/partials/landing_page.html
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 1 addition & 1 deletion modules/blox-tailwind/layouts/partials/site_head.html
Original file line number Diff line number Diff line change
Expand Up @@ -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" }}
<link href="{{ $styles.RelPermalink }}" rel="stylesheet" />
{{ else }}
Expand Down

0 comments on commit 2b11b7e

Please sign in to comment.