diff --git a/modules/blox-tailwind/layouts/_partials/functions/parse_block_v2.html b/modules/blox-tailwind/layouts/_partials/functions/parse_block_v2.html index 7605b579..68bbd508 100644 --- a/modules/blox-tailwind/layouts/_partials/functions/parse_block_v2.html +++ b/modules/blox-tailwind/layouts/_partials/functions/parse_block_v2.html @@ -5,7 +5,8 @@ {{ $page := .page }} {{ $block := .block }} -{{ $block_type := lower ($block.blox | default $block.block) | default "markdown" }} +{{- $block_type := partial "hbx/resolve-block-param" (dict "config" $block "context" "content section") | default "markdown" -}} +{{ $block_type = lower $block_type }} {{ range $r := site.Data.blox_aliases.renames }} {{ $block_type = cond (eq $block_type $r.old) $r.new $block_type }} {{ end }} diff --git a/modules/blox-tailwind/layouts/_partials/hbx/resolve-block-param.html b/modules/blox-tailwind/layouts/_partials/hbx/resolve-block-param.html new file mode 100644 index 00000000..eca17df3 --- /dev/null +++ b/modules/blox-tailwind/layouts/_partials/hbx/resolve-block-param.html @@ -0,0 +1,20 @@ +{{/* Context-aware block parameter resolution with backward compatibility */}} +{{/* Strategy: Prefers "block" over "blox" (legacy) in configs */}} +{{- $config := .config -}} +{{- $context := .context | default "component" -}} + +{{- $block_id := "" -}} +{{- $using_legacy := false -}} + +{{- if $config.block -}} + {{- $block_id = $config.block -}} +{{- else if $config.blox -}} + {{- $block_id = $config.blox -}} + {{- $using_legacy = true -}} +{{- end -}} + +{{- if $using_legacy -}} + {{- warnf "HBX: Using legacy 'blox' parameter for %s. Please update to 'block' for consistency. (Found: blox=%s)" $context $block_id -}} +{{- end -}} + +{{- return $block_id -}} diff --git a/modules/blox-tailwind/layouts/_partials/init.html b/modules/blox-tailwind/layouts/_partials/init.html index 324b05fd..9e499cf3 100644 --- a/modules/blox-tailwind/layouts/_partials/init.html +++ b/modules/blox-tailwind/layouts/_partials/init.html @@ -13,7 +13,8 @@ {{ 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" }} + {{- $block_type := partial "hbx/resolve-block-param" (dict "config" $block "context" "content section") | default "markdown" -}} + {{ $block_type = lower $block_type }} {{ range $r := .Site.Data.blox_aliases.renames }} {{ $block_type = cond (eq $block_type $r.old) $r.new $block_type }} {{ end }} diff --git a/modules/blox-tailwind/layouts/_partials/site_footer.html b/modules/blox-tailwind/layouts/_partials/site_footer.html index a3e66bf9..a65129d3 100644 --- a/modules/blox-tailwind/layouts/_partials/site_footer.html +++ b/modules/blox-tailwind/layouts/_partials/site_footer.html @@ -3,7 +3,8 @@ {{ partial "functions/get_hook" (dict "hook" "footer-start" "context" .) }} {{/* Load footer block */}} - {{ $footer_section_name := site.Params.footer.blox | default "minimal" }} + {{- $footer_config := site.Params.footer | default dict -}} + {{- $footer_section_name := partial "hbx/resolve-block-param" (dict "config" $footer_config "context" "footer") | default "minimal" -}} {{ $footer_section_path := printf "components/footers/%s.html" $footer_section_name }} {{ if not (templates.Exists (printf "_partials/%s" $footer_section_path)) }} {{ errorf "Check your `params.yaml`. Cannot find footer block at `layouts/_partials/%s`" $footer_section_path }} diff --git a/modules/blox-tailwind/layouts/baseof.html b/modules/blox-tailwind/layouts/baseof.html index cf6dbeaf..b445d946 100644 --- a/modules/blox-tailwind/layouts/baseof.html +++ b/modules/blox-tailwind/layouts/baseof.html @@ -11,7 +11,8 @@ {{/* Load header block */}} {{ $show_navbar := ((site.Params.header.navbar.enable | default true) | and (ne .Params.header.navbar.enable false)) | or .Params.header.navbar.enable }} {{ if $show_navbar }} - {{ $block_name := .Params.header.navbar.blox | default site.Params.header.navbar.blox | default "navbar" }} + {{- $header_config := .Params.header.navbar | default site.Params.header.navbar | default dict -}} + {{- $block_name := partial "hbx/resolve-block-param" (dict "config" $header_config "context" "header") | default "navbar" -}} {{ $block_path := printf "components/headers/%s.html" $block_name }} {{ if not (templates.Exists (printf "_partials/%s" $block_path)) }} {{ errorf "Check your `header` config in `params.yaml` and/or front matter. Cannot find header block at `layouts/_partials/%s`" $block_path }}