fix: init.html refactoring error

Removed Scratch access (which caused the interface/Site context error)

Rely on caching at callsite: partialCached "init.html" . "hb_init_once"
This commit is contained in:
George Cushen committed 2025-08-25 21:36:11 +01:00
1 parent 507f03411f
commit 76a0ca6fef
2 files changed
+22 -26

No files matched your search

@@ -1,32 +1,28 @@
{{/* Workaround Hugo concurrency issues (e.g. not detecting Page.Store variables) */}}
{{/* Use cases: Page.Store use within shortcodes, blox, and backlinks. */}}
{{/* See https://discourse.gohugo.io/t/persisting-data-across-the-build-of-a-site/41114/6 */}}
{{ $scr := site.Scratch }}
{{ if not ($scr.Get "hb_init_done") }}
{{ $scr.Set "hb_init_done" true }}
{{/* Pre-warm only content pages so Page.Store/backlinks are populated deterministically */}}
{{- range where site.Pages "Kind" "page" -}}
{{- $ := .Content -}}
{{- end -}}
{{/* Pre-warm only content pages so Page.Store/backlinks are populated deterministically */}}
{{- range where .Site.Pages "Kind" "page" -}}
{{- $ := .Content -}}
{{- end -}}
{{/* Preload block configs for landing pages */}}
{{- range where site.Pages "Type" "landing" -}}
{{ $page := . }}
{{ 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 "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 }}
{{ end }}
{{ $widget_config_file := printf "blox/%s--CONFIG.html" $block_type }}
{{ if templates.Exists (printf "_partials/%s" $widget_config_file) }}
{{ $hash_id := $block.id | default (printf "section-%s" (replace $block_type "." "-")) }}
{{ $widget_args := dict "wcPage" $page "wcBlock" $block "wcIdentifier" $hash_id }}
{{ partial $widget_config_file $widget_args }}
{{ end }}
{{/* Preload block configs for landing pages */}}
{{- range where .Site.Pages "Type" "landing" -}}
{{ $page := . }}
{{ 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 "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 }}
{{ end }}
{{ $widget_config_file := printf "blox/%s--CONFIG.html" $block_type }}
{{ if templates.Exists (printf "_partials/%s" $widget_config_file) }}
{{ $hash_id := $block.id | default (printf "section-%s" (replace $block_type "." "-")) }}
{{ $widget_args := dict "wcPage" $page "wcBlock" $block "wcIdentifier" $hash_id }}
{{ partial $widget_config_file $widget_args }}
{{ end }}
{{ end }}
{{- end -}}
{{ end }}
{{ end }}
{{- end -}}
@@ -209,7 +209,7 @@
{{/* Init prior to auto-chunking/bundling scripts due to Hugo concurrency issues */}}
{{/* !CACHED! Initialized once at site level and then cached for each page */}}
{{- partialCached "init.html" . -}}
{{- partialCached "init.html" . "hb_init_once" -}}
{{/* Load Third-Party Libraries */}}
{{ partial "libraries.html" . }}