mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-04 18:13:06 +00:00
feat(hugo): replace deprecated APIs for Hugo v0.156+ compatibility
Migrate site.Data → hugo.Data (42 occurrences), site.IsMultiLingual → hugo.IsMultilingual, and site.AllPages → hugo.Sites nested range. Simplify Netlify redirects template to use pre-processed aliases instead of relLangURL per gohugoio/hugo#14408.
This commit is contained in:
1 parent
94703c5c4f
commit
ef8ed449c7
25 files changed
+5824
-5838
No files matched your search
File diff suppressed because it is too large.
Load diff
+5204
-5213
File diff suppressed because it is too large.
Load diff
@@ -5,9 +5,9 @@
|
||||
{{- partial "functions/get_icon" (dict "name" "globe-alt" "attributes" `class="inline-block pr-1" style="height: 1em"`) -}}
|
||||
{{ i18n "languages" }}:
|
||||
</div>
|
||||
<div class="font-bold">{{ index site.Data.languages .Lang }}</div>
|
||||
<div class="font-bold">{{ index hugo.Data.languages .Lang }}</div>
|
||||
{{ range .Translations }}
|
||||
<div><a href="{{ .Permalink }}">{{ index site.Data.languages .Lang }}</a></div>
|
||||
<div><a href="{{ .Permalink }}">{{ index hugo.Data.languages .Lang }}</a></div>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
<li class="lg:px-2">
|
||||
<select onchange="document.documentElement.setAttribute('data-theme-pack', this.value); localStorage.setItem('hb-theme-pack', this.value);" class="bg-transparent text-[var(--hb-color-header-fg)] border-none focus:ring-0 cursor-pointer text-sm font-medium">
|
||||
<option value="">Theme</option>
|
||||
{{ range $name, $data := site.Data.themes }}
|
||||
{{ range $name, $data := hugo.Data.themes }}
|
||||
<option value="{{ $name }}">{{ $name | humanize }}</option>
|
||||
{{ end }}
|
||||
</select>
|
||||
|
||||
@@ -181,7 +181,7 @@
|
||||
<div class="px-3">
|
||||
<select onchange="document.documentElement.setAttribute('data-theme-pack', this.value); localStorage.setItem('hb-theme-pack', this.value);" class="bg-transparent text-[var(--hb-color-header-fg)] border-none focus:ring-0 cursor-pointer text-sm font-medium">
|
||||
<option value="">Theme</option>
|
||||
{{ range $name, $data := site.Data.themes }}
|
||||
{{ range $name, $data := hugo.Data.themes }}
|
||||
<option value="{{ $name }}">{{ $name | humanize }}</option>
|
||||
{{ end }}
|
||||
</select>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<div class="flex items-center gap-2 capitalize">
|
||||
{{/* Match theme chooser icon height */}}
|
||||
{{- partial "functions/get_icon" (dict "name" "globe-alt" "attributes" "height=18") -}}
|
||||
{{- if not $hide_language_name -}}<span>{{ index site.Data.languages $page.Lang }}</span>{{ end -}}
|
||||
{{- if not $hide_language_name -}}<span>{{ index hugo.Data.languages $page.Lang }}</span>{{ end -}}
|
||||
</div>
|
||||
</button>
|
||||
<ul
|
||||
@@ -29,7 +29,7 @@
|
||||
href="{{ .Permalink }}"
|
||||
class="relative cursor-pointer text-gray-800 dark:text-gray-100 hover:bg-primary-50 hover:text-primary-600 hover:dark:bg-primary-500/10 hover:dark:text-primary-200 whitespace-nowrap py-1.5 transition-colors ltr:pl-3 ltr:pr-9 rtl:pr-3 rtl:pl-9"
|
||||
>
|
||||
{{- index site.Data.languages .Lang -}}
|
||||
{{- index hugo.Data.languages .Lang -}}
|
||||
</a>
|
||||
</li>
|
||||
{{ end -}}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{{ if ne .Params.share false }}
|
||||
<section class="flex flex-row flex-wrap justify-center pt-4 text-xl">
|
||||
{{ range where site.Data.page_sharer.links "enable" true }}
|
||||
{{ range where hugo.Data.page_sharer.links "enable" true }}
|
||||
|
||||
{{/* mailto URIs require percent-encoding (%20 for spaces) per RFC 6068, not form-encoding (+ for spaces). */}}
|
||||
{{/* Use urls.PathEscape for mailto; urlquery for other schemes (https, etc.). */}}
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
{{ $page := .page }}
|
||||
{{ $is_list := .is_list }}
|
||||
|
||||
{{ $types := site.Data.link_types.types }}
|
||||
{{ $derived := site.Data.link_types.derived }}
|
||||
{{ $types := hugo.Data.link_types.types }}
|
||||
{{ $derived := hugo.Data.link_types.derived }}
|
||||
|
||||
{{ $links := slice }}
|
||||
{{ $seen := newScratch }}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
{{ $layout_config := .layout }}
|
||||
|
||||
<style>
|
||||
{{ range $pack_name, $pack_data := site.Data.themes }}
|
||||
{{ range $pack_name, $pack_data := hugo.Data.themes }}
|
||||
{{ if $pack_data.hugoblox }}
|
||||
{{ $theme := $pack_data.hugoblox }}
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
{{/* Function to return a formatted address given a semantic address. */}}
|
||||
|
||||
{{/* Check for valid site config. */}}
|
||||
{{ if not site.Data.address_formats }}{{errorf "Address formats missing from `data/address_formats.toml`!"}}{{end}}
|
||||
{{ if not hugo.Data.address_formats }}{{errorf "Address formats missing from `data/address_formats.toml`!"}}{{end}}
|
||||
|
||||
{{ $page := . }}
|
||||
{{ $address := .address }}
|
||||
{{ $format_name := $page.Params.address_format | default site.Params.hugoblox.locale.address_format | default "en-us" }}
|
||||
|
||||
{{ if not (isset site.Data.address_formats $format_name) }}{{ errorf "Address format `%s` missing from `data/address_formats.toml`!" $format_name }}{{end}}
|
||||
{{ if not (isset hugo.Data.address_formats $format_name) }}{{ errorf "Address format `%s` missing from `data/address_formats.toml`!" $format_name }}{{end}}
|
||||
|
||||
{{ $format := index site.Data.address_formats $format_name }}
|
||||
{{ $format := index hugo.Data.address_formats $format_name }}
|
||||
{{ $address_display := slice }}
|
||||
|
||||
{{ range $k, $v := $format.order }}
|
||||
|
||||
@@ -8,17 +8,17 @@
|
||||
Usage:
|
||||
{{ $authors := partialCached "functions/get_authors_data" . site.Language.Lang }}
|
||||
|
||||
Returns: map of slug → author data (same shape as site.Data.authors)
|
||||
Returns: map of slug → author data (same shape as hugo.Data.authors)
|
||||
*/}}
|
||||
|
||||
{{- $authors := site.Data.authors -}}
|
||||
{{- $authors := hugo.Data.authors -}}
|
||||
{{- if not $authors -}}
|
||||
{{- $authors = dict -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Check for language-specific author overrides */}}
|
||||
{{- $lang := site.Language.Lang -}}
|
||||
{{- $langData := index site.Data $lang -}}
|
||||
{{- $langData := index hugo.Data $lang -}}
|
||||
{{- if $langData -}}
|
||||
{{- $langAuthors := index $langData "authors" -}}
|
||||
{{- if $langAuthors -}}
|
||||
|
||||
@@ -22,14 +22,14 @@
|
||||
{{- $explicitPack := or (.pack) (strings.Contains .name "/") -}}
|
||||
|
||||
{{- /* Resolve icon aliases (e.g. brands/google-scholar → brands/googlescholar) */ -}}
|
||||
{{- with index site.Data.icons.aliases $pack -}}
|
||||
{{- with index hugo.Data.icons.aliases $pack -}}
|
||||
{{- with index . $name -}}
|
||||
{{- $name = . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $icon := "" -}}
|
||||
{{- $icon_pack := index site.Data.icons $pack -}}
|
||||
{{- $icon_pack := index hugo.Data.icons $pack -}}
|
||||
{{- $pack_icon := index (index $icon_pack "icons") $name -}}
|
||||
|
||||
{{- if $pack_icon -}}
|
||||
@@ -42,7 +42,7 @@
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- /* Icon not found in pack — try hb fallback, then user assets */ -}}
|
||||
{{- with index (index site.Data.icons.hb "icons") $name -}}
|
||||
{{- with index (index hugo.Data.icons.hb "icons") $name -}}
|
||||
{{- $icon = . -}}
|
||||
{{- else -}}
|
||||
{{- $prefix := printf "media/icons/%s/" $pack -}}
|
||||
@@ -73,7 +73,7 @@
|
||||
)
|
||||
}}
|
||||
{{- end -}}
|
||||
{{- with index (index site.Data.icons.brands "icons") "hugo" -}}
|
||||
{{- with index (index hugo.Data.icons.brands "icons") "hugo" -}}
|
||||
{{- $icon = printf `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">%s</svg>` (index . "body") -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
{{- $hb_icon_check := partial "functions/get_icon" (dict "name" "academic-cap" "attributes" "style=\"display: none;\"") -}}
|
||||
|
||||
{{/* Verify Hugo Blox data structures */}}
|
||||
{{- $hb_data_check := site.Data.icons.hero -}}
|
||||
{{- $hb_data_check := hugo.Data.icons.hero -}}
|
||||
|
||||
{{/* Verify Hugo Blox UID generation */}}
|
||||
{{- $hb_uid_check := partial "functions/uid.html" . -}}
|
||||
@@ -47,7 +47,7 @@
|
||||
{{- end -}}
|
||||
|
||||
{{/* Verify Hugo Blox brands icon pack */}}
|
||||
{{- $hb_brands_check := site.Data.icons.brands -}}
|
||||
{{- $hb_brands_check := hugo.Data.icons.brands -}}
|
||||
|
||||
{{/* Debug output to identify failing check (dev only) */}}
|
||||
{{- if getenv "HUGO_BLOX_DEBUG" -}}
|
||||
|
||||
@@ -29,13 +29,13 @@
|
||||
|
||||
{{ if $vendor }}
|
||||
{{/* Third-party font pack: data/fonts/vendor/name.yaml */}}
|
||||
{{ $vendor_fonts := index site.Data.fonts $vendor }}
|
||||
{{ $vendor_fonts := index hugo.Data.fonts $vendor }}
|
||||
{{ if $vendor_fonts }}
|
||||
{{ $raw_pack = index $vendor_fonts $name }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{/* Built-in or user font pack: data/fonts/name.yaml */}}
|
||||
{{ with index site.Data.fonts $name }}
|
||||
{{ with index hugo.Data.fonts $name }}
|
||||
{{ $raw_pack = . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
@@ -29,13 +29,13 @@
|
||||
|
||||
{{ if $vendor }}
|
||||
{{/* Third-party theme: data/themes/vendor/name.yaml */}}
|
||||
{{ $vendor_themes := index site.Data.themes $vendor }}
|
||||
{{ $vendor_themes := index hugo.Data.themes $vendor }}
|
||||
{{ if $vendor_themes }}
|
||||
{{ $raw_theme = index $vendor_themes $name }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{/* Built-in or user theme: data/themes/name.yaml */}}
|
||||
{{ $raw_theme = index site.Data.themes $name }}
|
||||
{{ $raw_theme = index hugo.Data.themes $name }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Validate theme structure */}}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
{{ $block_type = lower $block_type }}
|
||||
|
||||
{{/* Handle block renames/aliases */}}
|
||||
{{ range $r := site.Data.blox_aliases.renames }}
|
||||
{{ range $r := hugo.Data.blox_aliases.renames }}
|
||||
{{ $block_type = cond (eq $block_type $r.old) $r.new $block_type }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
{{ $surfaces_overrides := $config.surfaces | default dict }}
|
||||
|
||||
{{/* Load Theme Data using the new loader */}}
|
||||
{{ if not site.Data.themes }}
|
||||
{{ warnf "THEME ENGINE ERROR: site.Data.themes is empty! Check modules/blox-tailwind/data/themes/" }}
|
||||
{{ if not hugo.Data.themes }}
|
||||
{{ warnf "THEME ENGINE ERROR: hugo.Data.themes is empty! Check modules/blox-tailwind/data/themes/" }}
|
||||
{{ end }}
|
||||
|
||||
{{ $light_theme := partial "functions/load_theme_pack" $light_theme_name }}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
{{- with .Params.sections_source -}}
|
||||
{{- $key := . -}}
|
||||
{{- if hasPrefix $key "pages/" -}}{{- $key = (replace $key "pages/" "") -}}{{- end -}}
|
||||
{{- with index site.Data.pages $key -}}
|
||||
{{- with index hugo.Data.pages $key -}}
|
||||
{{- $base := .sections -}}
|
||||
{{- if $sections -}}
|
||||
{{- $merged := slice -}}
|
||||
@@ -53,7 +53,7 @@
|
||||
{{- if eq $.RelPermalink "/" -}}
|
||||
{{- $p = "home" -}}
|
||||
{{- end -}}
|
||||
{{- with index site.Data.pages $p -}}
|
||||
{{- with index hugo.Data.pages $p -}}
|
||||
{{- $sections = .sections -}}
|
||||
{{- $source = printf "data/pages/%s.yaml" $p -}}
|
||||
{{- end -}}
|
||||
@@ -68,7 +68,7 @@
|
||||
{{- $ref := . | lower -}}
|
||||
{{- $path := cond (hasPrefix $ref "blocks/") $ref (printf "blocks/%s" $ref) -}}
|
||||
{{- $parts := split $path "/" -}}
|
||||
{{- $data := site.Data -}}
|
||||
{{- $data := hugo.Data -}}
|
||||
{{- range $j, $p := $parts -}}
|
||||
{{- if $data -}}
|
||||
{{- $data = index $data $p -}}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
{{ with $page.Params.sections_source }}
|
||||
{{ $key := . }}
|
||||
{{ if hasPrefix $key "pages/" }}{{ $key = replace $key "pages/" "" }}{{ end }}
|
||||
{{ with index $.Site.Data.pages $key }}
|
||||
{{ with index hugo.Data.pages $key }}
|
||||
{{ $base := .sections }}
|
||||
{{ if $sections }}
|
||||
{{ $merged := slice }}
|
||||
@@ -54,7 +54,7 @@
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if eq $page.RelPermalink "/" }}{{ $p = "home" }}{{ end }}
|
||||
{{ with index $.Site.Data.pages $p }}
|
||||
{{ with index hugo.Data.pages $p }}
|
||||
{{ $sections = .sections }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
@@ -68,7 +68,7 @@
|
||||
{{ $ref := lower . }}
|
||||
{{ $path := cond (hasPrefix $ref "blocks/") $ref (printf "blocks/%s" $ref) }}
|
||||
{{ $parts := split $path "/" }}
|
||||
{{ $data := $.Site.Data }}
|
||||
{{ $data := hugo.Data }}
|
||||
{{ range $j, $p := $parts }}
|
||||
{{ if $data }}{{ $data = index $data $p }}{{ end }}
|
||||
{{ end }}
|
||||
@@ -87,7 +87,7 @@
|
||||
{{ if or (not $block.demo) ($block.demo | and (eq (os.Getenv "HUGO_BLOX_DEMO") "true")) }}
|
||||
{{- $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 }}
|
||||
{{ range $r := hugo.Data.blox_aliases.renames }}
|
||||
{{ $block_type = cond (eq $block_type $r.old) $r.new $block_type }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
{{ $content_dir = site.Params.hugoblox.repository.content_dir }}
|
||||
{{else}}
|
||||
{{/* Attempt to get content dir from the LanguagePrefix URI, but defaultContentLanguageInSubdir can break this assumption. */}}
|
||||
{{ $content_dir = cond site.IsMultiLingual (cond (ne .Site.LanguagePrefix "") (printf "%s%s" $content_dir .Site.LanguagePrefix) $content_dir) $content_dir }}
|
||||
{{ $content_dir = cond hugo.IsMultilingual (cond (ne .Site.LanguagePrefix "") (printf "%s%s" $content_dir .Site.LanguagePrefix) $content_dir) $content_dir }}
|
||||
{{end}}
|
||||
<p class="edit-page">
|
||||
<a href="{{site.Params.hugoblox.repository.url}}/edit/{{site.Params.hugoblox.repository.branch | default "main"}}/{{$content_dir}}/{{.File.Path}}">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="generator" content="Hugo Blox Kit {{ site.Data.hugoblox.version }}" />
|
||||
<meta name="generator" content="Hugo Blox Kit {{ hugo.Data.hugoblox.version }}" />
|
||||
|
||||
{{/* EXTENSIBILITY HOOK: HEAD-START */}}
|
||||
{{ partial "functions/get_hook" (dict "hook" "head-start" "context" .) }}
|
||||
@@ -232,7 +232,7 @@
|
||||
{{/* !CACHED! Initialized once at site level and then cached for each page */}}
|
||||
{{- partialCached "init.html" . "hb_init_once" -}}
|
||||
|
||||
{{ $js_license := printf "/*! Hugo Blox Kit Tailwind UI v%s | https://hugoblox.com/ */\n" site.Data.hugoblox.version }}
|
||||
{{ $js_license := printf "/*! Hugo Blox Kit Tailwind UI v%s | https://hugoblox.com/ */\n" hugo.Data.hugoblox.version }}
|
||||
{{ $js_license := $js_license | printf "%s/*! Copyright 2016-present George Cushen (https://georgecushen.com/) */\n" }}
|
||||
{{ $js_license := $js_license | printf "%s/*! License: https://github.com/HugoBlox/kit/blob/main/LICENSE.md */\n" }}
|
||||
{{ $js_bundle_head := $js_license | resources.FromString "js/bundle-head.js" }}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{{ "<!-- This site was created with Hugo Blox. https://hugoblox.com -->" | safeHTML }}
|
||||
{{ printf "<!-- Last Published: %s -->" (now | time.Format ":date_long") | safeHTML }}
|
||||
{{- $language_code := site.LanguageCode | default "en-us" -}}
|
||||
<html lang="{{$language_code}}" {{ if in site.Data.i18n.rtl.rtl $language_code }}dir="rtl"{{else}}dir="ltr"{{end}}
|
||||
<html lang="{{$language_code}}" {{ if in hugo.Data.i18n.rtl.rtl $language_code }}dir="rtl"{{else}}dir="ltr"{{end}}
|
||||
data-wc-theme-default="{{ (lower site.Params.hugoblox.theme.mode) | default "system" }}"
|
||||
data-hbb-relurl="{{ "" | relURL }}">
|
||||
{{ partial "site_head" . }}
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
# Automatically generated
|
||||
# Documentation: https://docs.netlify.com/routing/redirects/
|
||||
{{- /* Note: code purposely un-indented to preserve required spacing in output. */ -}}
|
||||
{{- range $page := where site.AllPages ".Aliases" "!=" nil -}}
|
||||
{{- range $s := hugo.Sites -}}
|
||||
{{- range $page := where $s.Pages ".Aliases" "!=" nil -}}
|
||||
{{- range $page.Aliases }}
|
||||
{{ .|relLangURL }} {{ $page.RelPermalink -}}
|
||||
{{ . }} {{ $page.RelPermalink -}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
<!doctype html>
|
||||
{{- $language_code := site.LanguageCode | default "en-us" -}}
|
||||
<html lang="{{$language_code}}" {{ if in site.Data.i18n.rtl.rtl $language_code }}dir="rtl"{{else}}dir="ltr"{{end}}
|
||||
<html lang="{{$language_code}}" {{ if in hugo.Data.i18n.rtl.rtl $language_code }}dir="rtl"{{else}}dir="ltr"{{end}}
|
||||
data-wc-theme-default="{{ (lower site.Params.hugoblox.theme.mode) | default "system" }}"
|
||||
data-hbb-relurl="{{ "" | relURL }}">
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
<!doctype html>
|
||||
{{- $language_code := site.LanguageCode | default "en-us" -}}
|
||||
<html lang="{{$language_code}}" {{ if in site.Data.i18n.rtl.rtl $language_code }}dir="rtl"{{else}}dir="ltr"{{end}}>
|
||||
<html lang="{{$language_code}}" {{ if in hugo.Data.i18n.rtl.rtl $language_code }}dir="rtl"{{else}}dir="ltr"{{end}}>
|
||||
<head>
|
||||
|
||||
{{/* Asset versions */}}
|
||||
@@ -33,7 +33,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="generator" content="HugoBlox Kit {{with site.Data.hugoblox.version}}{{.}}{{end}}">
|
||||
<meta name="generator" content="HugoBlox Kit {{with hugo.Data.hugoblox.version}}{{.}}{{end}}">
|
||||
|
||||
{{ with site.Home.OutputFormats.Get "WebAppManifest" }}
|
||||
<link rel="manifest" href="{{ .RelPermalink }}">
|
||||
|
||||
Reference in new issue
Block a user