mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-14 00:16:31 +00:00
feat: rename footer/header blox param to block
This commit is contained in:
1 parent
9a3f497031
commit
135c6fb0b6
5 files changed
+28
-4
No files matched your search
@@ -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 }}
|
||||
|
||||
@@ -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 -}}
|
||||
@@ -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 }}
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
Reference in new issue
Block a user