From 214ed09d20f7f50f39938f469156f03551e56c92 Mon Sep 17 00:00:00 2001 From: Mark Dumay <61946753+markdumay@users.noreply.github.com> Date: Thu, 16 Jul 2026 12:34:19 +0200 Subject: [PATCH 1/2] fix: update mod-utils to v6.6.0 Adopt the mod-utils release that adds the page argument to AddModule (dual-write) and the new pure utilities/GetBaseURL.html helper. hugo mod get dragged mod-fontawesome to v6.1.0 and Font-Awesome to 20260715; both were pinned back so this bump changes mod-utils only. Tidying the exampleSite removes its redundant mod-utils requirement: the hinode.work workspace already resolves the module through the theme's own go.mod. Co-Authored-By: Claude Fable 5 --- exampleSite/go.mod | 1 - exampleSite/go.sum | 2 -- go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/exampleSite/go.mod b/exampleSite/go.mod index 68742a3ac..7e3aefb2c 100644 --- a/exampleSite/go.mod +++ b/exampleSite/go.mod @@ -10,6 +10,5 @@ require ( github.com/gethinode/mod-cookieyes/v2 v2.2.6 // indirect github.com/gethinode/mod-docs v1.15.2 // indirect github.com/gethinode/mod-fontawesome/v6 v6.0.2 // indirect - github.com/gethinode/mod-utils/v6 v6.5.1 // indirect github.com/twbs/icons v1.13.1 // indirect ) diff --git a/exampleSite/go.sum b/exampleSite/go.sum index bf0fd7283..8e3bc6680 100644 --- a/exampleSite/go.sum +++ b/exampleSite/go.sum @@ -12,7 +12,5 @@ github.com/gethinode/mod-docs v1.15.2 h1:ZuOO/M5KyuUNGEoId+rManHG/L3WBboXG9L/ikS github.com/gethinode/mod-docs v1.15.2/go.mod h1:ru1w0fHqFocjDIMV0dm40OwhBw5k4UncCS8iO/1S5kI= github.com/gethinode/mod-fontawesome/v6 v6.0.2 h1:MxaHU7MZIh4pgxtoR6C/F0qiB5eSiySmRpTw9DGIOVs= github.com/gethinode/mod-fontawesome/v6 v6.0.2/go.mod h1:Zy+hjVhFDU52nkTIn9btbZ1PWy2n203zKHiPG9RVSL0= -github.com/gethinode/mod-utils/v6 v6.5.1 h1:HhCN8Bc0cWxIY0ukjKP9O3jDbKg9F/YaTPO6vqjjk+I= -github.com/gethinode/mod-utils/v6 v6.5.1/go.mod h1:E5tO9w3VKaidJpu1nI8zAKmh0bddFHOIIQnudAaXQTs= github.com/twbs/icons v1.13.1 h1:6bmNXvoeIbvjFWjfbjXg5JGbelLD1haIsMaEIzE9UZI= github.com/twbs/icons v1.13.1/go.mod h1:GnRlymgVWp5iVJCMa0Me5b6tFyGpVc2bSxPMRGIJmyA= diff --git a/go.mod b/go.mod index 844f3996a..09754751a 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/gethinode/mod-lottie/v3 v3.0.2 // indirect github.com/gethinode/mod-mermaid/v5 v5.0.1 // indirect github.com/gethinode/mod-simple-datatables/v4 v4.1.0 // indirect - github.com/gethinode/mod-utils/v6 v6.5.1 // indirect + github.com/gethinode/mod-utils/v6 v6.6.0 // indirect github.com/nextapps-de/flexsearch v0.0.0-20260529083235-f7ed963096a0 // indirect github.com/twbs/bootstrap v5.3.8+incompatible // indirect ) diff --git a/go.sum b/go.sum index 0e844bdbc..152a70981 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/gethinode/mod-mermaid/v5 v5.0.1 h1:heGJ9i3rDXAh+qU8N0jSEPhVGOsQwxLpNm github.com/gethinode/mod-mermaid/v5 v5.0.1/go.mod h1:3M0XrI6Ginj5EIbXy1xOymv3KsfPuBhD07FEPz1SikI= github.com/gethinode/mod-simple-datatables/v4 v4.1.0 h1:AtEtLH9RoAEIpElg0k6UkVlHmiBc4Df3NCCUfBtmktU= github.com/gethinode/mod-simple-datatables/v4 v4.1.0/go.mod h1:jRHoX20bUiaVg7UtKzMjfHQjd5M6WZ8hAeVqA3TKwTA= -github.com/gethinode/mod-utils/v6 v6.5.1 h1:HhCN8Bc0cWxIY0ukjKP9O3jDbKg9F/YaTPO6vqjjk+I= -github.com/gethinode/mod-utils/v6 v6.5.1/go.mod h1:E5tO9w3VKaidJpu1nI8zAKmh0bddFHOIIQnudAaXQTs= +github.com/gethinode/mod-utils/v6 v6.6.0 h1:b+xpvPUqDKcQr1LUU4YKqtr7zIpzZ7zxCrlpLtlyr5Y= +github.com/gethinode/mod-utils/v6 v6.6.0/go.mod h1:E5tO9w3VKaidJpu1nI8zAKmh0bddFHOIIQnudAaXQTs= github.com/nextapps-de/flexsearch v0.0.0-20260529083235-f7ed963096a0 h1:QDKcU3q39lFGzdVwM6kgCGnW3ibbMfYIi0Rwl62iJpo= github.com/nextapps-de/flexsearch v0.0.0-20260529083235-f7ed963096a0/go.mod h1:5GdMfPAXzbA2gXBqTjC6l27kioSYzHlqDMh0+wyx7sU= github.com/twbs/bootstrap v5.3.8+incompatible h1:eK1fsXP7R/FWFt+sSNmmvUH9usPocf240nWVw7Dh02o= From d970b53465ce858e59ec04aa623aba4bea9d614a Mon Sep 17 00:00:00 2001 From: Mark Dumay <61946753+markdumay@users.noreply.github.com> Date: Thu, 16 Jul 2026 12:34:45 +0200 Subject: [PATCH 2/2] fix: thread the intrinsic page through content-reachable partials Remove the remaining global-page reads in content-reachable hinode partials (render-once slice D5), so a page's output no longer depends on the ambient rendering context: - section-title: new optional page argument; CurrentSection and the seven RenderString sites now use the threaded page. Callers (articles, timeline) pass the page explicitly. - card: title RenderString uses the card's target page (or the caller's page); card-group, articles, and the card shortcode thread the page; the thumbnail hook receives it too. - image: title-casing reads the threaded page's exact param; all in-tree callers (thumbnail, navbar and sidebar logos, persona, GetIllustration, featured-illustration) pass the page. - links, download, adapters/hugo: bare global page fills replaced by the threaded page; the page is threaded through image-dimension and image-set into the CDN adapter interface. - navbar and navbar-item resolve the base URL via the pure cached GetBaseURL helper from mod-utils v6.6.0 instead of the baseof-seeded scratch value. - new utilities/GetVersionedMenu.html helper shares the version/sidebar-menu/IsOlder logic of baseof.html; navbar and page-alert consume it via partialCached instead of scratch reads. - table shortcode reads the module configuration from the cached InitModules partial instead of the baseof-seeded scratch value. - card-group stores the paginator on the threaded page instead of the global page. - toc-parse-content drops the unused Headings/HeadingsMap page store reads (maintainer decision Q2: retire). Per maintainer decision Q6, partials that gain a page argument fall back to the global page with a one-release warning when the argument is omitted; the warning output is captured so it cannot leak whitespace into rendered content. The exampleSite suppresses the warning until it picks up the mod-blocks release that threads the page (render-once slice D4). Co-Authored-By: Claude Fable 5 --- data/structures/card.yml | 2 + data/structures/download.yml | 2 + data/structures/image-adapter.yml | 2 + data/structures/image-set.yml | 2 + data/structures/section-title.yml | 2 + exampleSite/config/_default/hugo.toml | 5 ++- layouts/_partials/assets/adapters/hugo.html | 15 ++++++- layouts/_partials/assets/card-group.html | 3 +- layouts/_partials/assets/card.html | 22 +++++++++- layouts/_partials/assets/download.html | 15 ++++++- .../assets/featured-illustration.html | 1 + .../assets/helpers/image-dimension.html | 6 ++- .../_partials/assets/helpers/image-set.html | 3 +- .../_partials/assets/helpers/navbar-item.html | 2 +- layouts/_partials/assets/image.html | 17 +++++++- layouts/_partials/assets/links.html | 23 ++++++++-- layouts/_partials/assets/navbar.html | 7 +++- layouts/_partials/assets/page-alert.html | 14 +++++-- layouts/_partials/assets/persona.html | 1 + layouts/_partials/assets/section-title.html | 37 +++++++++++----- layouts/_partials/assets/sidebar.html | 2 + layouts/_partials/assets/timeline.html | 1 + .../_partials/assets/toc-parse-content.html | 10 ++--- layouts/_partials/page/articles.html | 3 ++ layouts/_partials/page/thumbnail.html | 1 + .../_partials/utilities/GetIllustration.html | 1 + .../_partials/utilities/GetVersionedMenu.html | 42 +++++++++++++++++++ layouts/_shortcodes/card.html | 1 + layouts/_shortcodes/table.html | 5 ++- layouts/baseof.html | 19 ++++----- layouts/toc.html | 3 +- 31 files changed, 218 insertions(+), 51 deletions(-) create mode 100644 layouts/_partials/utilities/GetVersionedMenu.html diff --git a/data/structures/card.yml b/data/structures/card.yml index 2d77b9fa5..597a80412 100644 --- a/data/structures/card.yml +++ b/data/structures/card.yml @@ -3,6 +3,8 @@ comment: >- such as title, href, and thumbnail override the corresponding page attributes. icon: article arguments: + page: + optional: true title: optional: true preview: true diff --git a/data/structures/download.yml b/data/structures/download.yml index 01c28dced..b29fd5b4a 100644 --- a/data/structures/download.yml +++ b/data/structures/download.yml @@ -1,6 +1,8 @@ comment: Generates a download button or link. group: partial arguments: + page: + optional: true download: title: class: diff --git a/data/structures/image-adapter.yml b/data/structures/image-adapter.yml index dec012185..668f60610 100644 --- a/data/structures/image-adapter.yml +++ b/data/structures/image-adapter.yml @@ -2,6 +2,8 @@ comment: >- Defines the interface to be implemented by a CDN image adapter. group: partial arguments: + page: + optional: true url-host: release: v1.0.0 url-dir: diff --git a/data/structures/image-set.yml b/data/structures/image-set.yml index 33b27da7e..acffa04d7 100644 --- a/data/structures/image-set.yml +++ b/data/structures/image-set.yml @@ -3,6 +3,8 @@ comment: >- hook, including transform, format, and anchor options. group: partial arguments: + page: + optional: true src: img: absolute-url: diff --git a/data/structures/section-title.yml b/data/structures/section-title.yml index b128ad81c..d186ccd3e 100644 --- a/data/structures/section-title.yml +++ b/data/structures/section-title.yml @@ -3,6 +3,8 @@ comment: >- layout options. group: partial arguments: + page: + optional: true heading: links: color: diff --git a/exampleSite/config/_default/hugo.toml b/exampleSite/config/_default/hugo.toml index 9e70213ba..dc48a643b 100644 --- a/exampleSite/config/_default/hugo.toml +++ b/exampleSite/config/_default/hugo.toml @@ -12,7 +12,10 @@ enableInlineShortcodes = true # prevent build failures when using Hugo's Instagram shortcode due to deprecated Instagram API. # See https://github.com/gohugoio/hugo/issues/7228#issuecomment-714490456 -ignoreErrors = ["error-remote-getjson", "warn-preview-restricted"] +# the transitional 'warn-missing-page-argument' entry suppresses the fallback warning raised by +# mod-blocks <= v2.1.4, which calls the section-title / image partials without a page argument; +# remove it once the exampleSite picks up the mod-blocks release that threads the page explicitly. +ignoreErrors = ["error-remote-getjson", "warn-preview-restricted", "warn-missing-page-argument"] timeout = "180s" languageCode = "en-us" diff --git a/layouts/_partials/assets/adapters/hugo.html b/layouts/_partials/assets/adapters/hugo.html index 5e34d6dc7..8d0efadd6 100644 --- a/layouts/_partials/assets/adapters/hugo.html +++ b/layouts/_partials/assets/adapters/hugo.html @@ -41,9 +41,22 @@ {{ $height := or $args.imageHeight $args.height -}} {{ $width := or $args.imageWidth $args.width -}} +{{/* Resolve the intrinsic page; fall back to the global page for one release */}} +{{- $page := $args.page -}} +{{- if not $page -}} + {{- $noop := partial "utilities/LogWarn.html" (dict + "partial" "assets/adapters/hugo.html" + "warnid" "warn-missing-page-argument" + "msg" "Missing argument 'page', falling back to the global page context" + "details" (slice "Pass the rendering page explicitly; this fallback will be removed in a future release") + "file" page.File + ) -}} + {{- $page = page -}} +{{- end -}} + {{/* Initialize image if needed, do not raise additional warnings */}} {{ if and (not $img) (ne $args.format "svg") }} - {{- $res := partial "utilities/GetImage.html" (dict "url" $url "page" page) -}} + {{- $res := partial "utilities/GetImage.html" (dict "url" $url "page" $page) -}} {{ if $res }} {{ $img = $res.resource }} {{/* TODO: $res.mirror */}} diff --git a/layouts/_partials/assets/card-group.html b/layouts/_partials/assets/card-group.html index c4dfc6d45..ce724ea06 100644 --- a/layouts/_partials/assets/card-group.html +++ b/layouts/_partials/assets/card-group.html @@ -74,7 +74,7 @@ {{- end -}} {{- $list = first $paginator.PagerSize (after (mul (sub $paginator.PageNumber 1) $paginator.PagerSize) $list) -}} - {{- page.Store.Set "paginator" $paginator -}} + {{- $args.page.Store.Set "paginator" $paginator -}} {{- end -}} {{/* Initialize list elements */}} @@ -148,6 +148,7 @@ {{- if $args.bento }}{{ with $args.valign }} align-items-{{ . }}{{ end }}{{ else }} {{ $colGrid }}{{ end }}"> {{- range $index, $element := $elements -}} {{- $params := (dict + "page" $args.page "class" $class "color" $args.color "header-style" (or $args.headerStyle $args.header) diff --git a/layouts/_partials/assets/card.html b/layouts/_partials/assets/card.html index 0b0c842eb..01fd7de15 100644 --- a/layouts/_partials/assets/card.html +++ b/layouts/_partials/assets/card.html @@ -25,6 +25,7 @@ {{/* Inline partial to render the card's body */}} {{- define "_partials/inline/card-body.html" -}} + {{- $page := .page -}} {{- $title := .title -}} {{- $href := .href -}} {{- $color := .color -}} @@ -38,7 +39,7 @@ {{ if or $title $links }}

- {{- with $title }}{{ . | page.RenderString }}{{ end }} + {{- with $title }}{{ . | $page.RenderString }}{{ end }} {{ with $links }}{{ partial "inline/card-icons.html" (dict "links" .) }}{{ end -}} {{- with $linkIcon -}}{{- partial "assets/icon.html" (dict "icon" . "spacing" false) -}}{{- end -}}

@@ -53,7 +54,7 @@ {{ if or $title $links }}

- {{- with $title }}{{ . | page.RenderString }}{{ end }} + {{- with $title }}{{ . | $page.RenderString }}{{ end }} {{ with $links }}{{ partial "inline/card-icons.html" (dict "links" .) }}{{ end -}}

{{ end -}} @@ -162,6 +163,20 @@ {{- if not $args.mode }}{{ $mode = (or (and (reflect.IsMap .Params.Thumbnail) .Params.Thumbnail.mode) false) }}{{ end -}} {{- end -}} +{{/* Resolve the page used for inline markdown rendering; prefer the card's target page and + fall back to the global page for one release */}} +{{- $renderPage := or $page $args.page -}} +{{- if not $renderPage -}} + {{- $noop := partial "utilities/LogWarn.html" (dict + "partial" "assets/card.html" + "warnid" "warn-missing-page-argument" + "msg" "Missing argument 'page', falling back to the global page context" + "details" (slice "Pass the rendering page explicitly; this fallback will be removed in a future release") + "file" page.File + ) -}} + {{- $renderPage = page -}} +{{- end -}} + {{- $style := $args.iconStyle }} {{ if (hasPrefix $args.orientation "horizontal") }} {{ if not $args.iconStyle }}{{ $style = "fa-fluid fa-fw" }}{{ end }} @@ -182,6 +197,7 @@ {{- $linkIcon := cond (and $linkIconEnabled $href (not $args.button) (not $args.buttonLabel)) $cardLinkIcon "" -}} {{- $thumbnailArgs := dict + "page" $renderPage "src" $thumbnail "portrait" $args.portrait "anchor" $anchor @@ -246,6 +262,7 @@ {{ end }} {{- partial "inline/card-body.html" (dict + "page" $renderPage "title" (cond $minimal "" $title) "href" $href "color" $args.color @@ -308,6 +325,7 @@ {{- if $overlay }}data-bs-theme="dark"{{ end }}> {{ if $page }}{{- partial "inline/card-caption.html" (dict "page" $page "keywords" $args.headerStyle "color" $args.color) -}}{{ end }} {{- partial "inline/card-body.html" (dict + "page" $renderPage "title" (cond $minimal "" $title) "href" $href "color" $args.color diff --git a/layouts/_partials/assets/download.html b/layouts/_partials/assets/download.html index 26d0883fe..d34eae9cd 100644 --- a/layouts/_partials/assets/download.html +++ b/layouts/_partials/assets/download.html @@ -19,9 +19,22 @@ {{ $error = $args.err }} {{ end }} +{{/* Resolve the intrinsic page; fall back to the global page for one release */}} +{{- $page := $args.page -}} +{{- if not $page -}} + {{- $noop := partial "utilities/LogWarn.html" (dict + "partial" "assets/download.html" + "warnid" "warn-missing-page-argument" + "msg" "Missing argument 'page', falling back to the global page context" + "details" (slice "Pass the rendering page explicitly; this fallback will be removed in a future release") + "file" page.File + ) -}} + {{- $page = page -}} +{{- end -}} + {{ $download := "" }} {{ if not $error }} - {{- $download = partial "utilities/GetTargetPath.html" (dict "path" $args.download "page" page) -}} + {{- $download = partial "utilities/GetTargetPath.html" (dict "path" $args.download "page" $page) -}} {{- if and $download (not (fileExists (path.Join "static" $download))) -}} {{ if page.File }} {{- errorf "Cannot find download file for page '%s': %s" page.File.Path $download -}} diff --git a/layouts/_partials/assets/featured-illustration.html b/layouts/_partials/assets/featured-illustration.html index 9181a5acd..a169d8bb2 100644 --- a/layouts/_partials/assets/featured-illustration.html +++ b/layouts/_partials/assets/featured-illustration.html @@ -45,6 +45,7 @@ {{- else if $image -}} {{- if not (hasSuffix $image "svg") }}{{ $class = strings.TrimSpace (printf "%s rounded" (or $class "")) }}{{ end -}} {{- partial "assets/live-image.html" (dict + "page" $args.page "src" $image "anchor" $args.anchor "ratio" $args.ratio diff --git a/layouts/_partials/assets/helpers/image-dimension.html b/layouts/_partials/assets/helpers/image-dimension.html index 875cfd4c9..c55161c67 100644 --- a/layouts/_partials/assets/helpers/image-dimension.html +++ b/layouts/_partials/assets/helpers/image-dimension.html @@ -143,7 +143,8 @@ {{ if or (hasSuffix $src "svg") $isStatic $args.plain }} {{- $targetURL = partial "utilities/GetStaticURL" (dict "url" $staticPath) -}} {{ else if (gt (len $dims) 0) }} - {{- $targetURL = partial "assets/helpers/image-set.html" (dict + {{- $targetURL = partial "assets/helpers/image-set.html" (dict + "page" $args.page "src" $src "img" (partial "utilities/OmitEmpty.html" $img) "dims" ($dims | last 1) @@ -154,7 +155,8 @@ "include-width" false )}} {{ if $args.imageset }} - {{- $set = partial "assets/helpers/image-set.html" (dict + {{- $set = partial "assets/helpers/image-set.html" (dict + "page" $args.page "src" $src "img" (partial "utilities/OmitEmpty.html" $img) "dims" $dims diff --git a/layouts/_partials/assets/helpers/image-set.html b/layouts/_partials/assets/helpers/image-set.html index fb9da56b7..2211e2c7d 100644 --- a/layouts/_partials/assets/helpers/image-set.html +++ b/layouts/_partials/assets/helpers/image-set.html @@ -38,7 +38,8 @@ {{ $width := (int (index (split $dim "x") 0)) }} {{ $height := (int (index (split $dim "x") 1)) }} - {{- $element := partial $adapter (dict + {{- $element := partial $adapter (dict + "page" $args.page "url-host" $host "url-dir" $dir "url-file" $file diff --git a/layouts/_partials/assets/helpers/navbar-item.html b/layouts/_partials/assets/helpers/navbar-item.html index ebf6796fe..a521f4ed1 100644 --- a/layouts/_partials/assets/helpers/navbar-item.html +++ b/layouts/_partials/assets/helpers/navbar-item.html @@ -38,7 +38,7 @@ {{- $tab := site.Params.main.externalLinks.tab -}} {{- if (isset $params "tab") }}{{ $tab = $params.tab }}{{ end -}} {{- $externalLink := partial "utilities/GetThemeIcon.html" (dict "id" "externalLink" "default" "fas up-right-from-square") -}} -{{- $baseURL := $page.Scratch.Get "baseURL" | default "/" -}} +{{- $baseURL := partialCached "utilities/GetBaseURL.html" site | default "/" -}} {{- $menuURL := "" -}} {{ if or (strings.HasPrefix $entry.PageRef "http") (strings.HasPrefix $entry.URL "http") }} {{ $menuURL = or $entry.PageRef $entry.URL }} diff --git a/layouts/_partials/assets/image.html b/layouts/_partials/assets/image.html index c16f67a46..932d93914 100644 --- a/layouts/_partials/assets/image.html +++ b/layouts/_partials/assets/image.html @@ -19,13 +19,26 @@ {{- $error = $args.err -}} {{- end -}} +{{/* Resolve the intrinsic page; fall back to the global page for one release */}} +{{- $page := $args.page -}} +{{- if not $page -}} + {{- $noop := partial "utilities/LogWarn.html" (dict + "partial" "assets/image.html" + "warnid" "warn-missing-page-argument" + "msg" "Missing argument 'page', falling back to the global page context" + "details" (slice "Pass the rendering page explicitly; this fallback will be removed in a future release") + "file" page.File + ) -}} + {{- $page = page -}} +{{- end -}} + {{/* Initialize global arguments */}} {{- $absoluteURL := site.Params.main.canonifyAssetsURLs | default false -}} {{- $modes := site.Params.main.modes | default (slice "light" "dark") -}} {{/* Initialize local arguments */}} {{- $caption := $args.caption -}} -{{- if and site.Params.main.titleCase (not page.Params.exact) (eq $caption (plainify $caption)) -}} +{{- if and site.Params.main.titleCase (not $page.Params.exact) (eq $caption (plainify $caption)) -}} {{- $caption = title $caption -}} {{- end -}} {{- $src := or $args.src $args.url -}} @@ -33,7 +46,7 @@ {{/* Main code */}} {{- $params := dict -}} {{- $params = merge $params (dict - "page" $args.page + "page" $page "ratio" $args.ratio "portrait" $args.portrait "image-width" $args.imageWidth diff --git a/layouts/_partials/assets/links.html b/layouts/_partials/assets/links.html index 997f0c16f..761719b0d 100644 --- a/layouts/_partials/assets/links.html +++ b/layouts/_partials/assets/links.html @@ -19,11 +19,25 @@ {{ $error = $args.err }} {{ end }} +{{/* Resolve the intrinsic page; fall back to the global page for one release */}} +{{- $page := $args.page -}} +{{- if not $page -}} + {{- $noop := partial "utilities/LogWarn.html" (dict + "partial" "assets/links.html" + "warnid" "warn-missing-page-argument" + "msg" "Missing argument 'page', falling back to the global page context" + "details" (slice "Pass the rendering page explicitly; this fallback will be removed in a future release") + "file" page.File + ) -}} + {{- $page = page -}} +{{- end -}} + {{/* Initialize global arguments */}} {{- $breakpoint := page.Scratch.Get "breakpoint" -}} {{- $padding := partial "utilities/GetPadding.html" -}} {{- define "_partials/links-content.html" -}} + {{- $page := .page -}} {{ $links := .links }} {{ $justify := .justify }} {{ $type := .type }} @@ -40,7 +54,7 @@ {{ $url := "" }} {{ with .url }} - {{ $link := partial "utilities/GetLink.html" (dict "page" page "href" .) }} + {{ $link := partial "utilities/GetLink.html" (dict "page" $page "href" .) }} {{ if not $link.error }} {{ $url = $link.href }} {{ else }} @@ -54,7 +68,8 @@ {{ if (eq $li true) }}
{{ end }} {{ if .download }} - {{ partial "assets/download.html" (dict + {{ partial "assets/download.html" (dict + "page" $page "download" .download "title" $title "icon" .icon @@ -96,9 +111,9 @@ {{ end }}
- {{ partial "links-content.html" (dict "links" $args.links "justify" $args.justify "type" $args.linkType "li" false) }} + {{ partial "links-content.html" (dict "page" $page "links" $args.links "justify" $args.justify "type" $args.linkType "li" false) }}
- {{ partial "links-content.html" (dict "links" $args.links "justify" $args.justify "type" $args.linkType "li" false) }} + {{ partial "links-content.html" (dict "page" $page "links" $args.links "justify" $args.justify "type" $args.linkType "li" false) }}
diff --git a/layouts/_partials/assets/navbar.html b/layouts/_partials/assets/navbar.html index 69ccf0aea..93b1567b2 100644 --- a/layouts/_partials/assets/navbar.html +++ b/layouts/_partials/assets/navbar.html @@ -50,7 +50,7 @@ {{- $pretty := site.Params.main.internalLinks.pretty | default false }} {{- $id := $args.id | default (printf "navbar-%d" 0) -}} {{- $page := $args.page -}} -{{- $baseURL := $page.Scratch.Get "baseURL" -}} +{{- $baseURL := partialCached "utilities/GetBaseURL.html" site -}} {{- $breakpoint := or $args.breakpoint $args.size }} {{- $defaultMenu := "main" -}} @@ -107,6 +107,7 @@ {{ $height := index site.Params.navigation "logo-height" | default 30 }} {{ $class := cond (eq $align "start") "my-auto" "m-auto" }} {{ $logo = partial "assets/image.html" (dict + "page" $page "src" . "loading" "eager" "title" $title @@ -147,7 +148,9 @@ In shell mode, the L1 sidebar lives outside the navbar at ≥breakpoint and the offcanvas toggler is emitted at the trailing edge below instead. */}} - {{ $sidebar := $page.Scratch.Get "sidebar" }} + {{ $version := partial "utilities/GetVersion.html" (dict "page" $page "base" true) }} + {{ $disable := eq (index $page.Params "sidebar-menu") false }} + {{ $sidebar := (partialCached "utilities/GetVersionedMenu.html" (dict "page" $page "version" $version) $page.Section $version $page.Kind $disable).menu }} {{- if and (not $shell) (or $sidebar (eq $align "center")) -}}
{{- if $sidebar -}} diff --git a/layouts/_partials/assets/page-alert.html b/layouts/_partials/assets/page-alert.html index b947cc4a4..024bcf14d 100644 --- a/layouts/_partials/assets/page-alert.html +++ b/layouts/_partials/assets/page-alert.html @@ -17,9 +17,17 @@ {{ end }} {{/* Initialize local arguments */}} -{{- $pageAlertMsg := $args.page.Scratch.Get "pageAlertMsg" -}} -{{- $pageAlertURL := $args.page.Scratch.Get "pageAlertURL" -}} -{{- $version := $args.page.Scratch.Get "version" -}} +{{- $page := $args.page -}} +{{- $version := partial "utilities/GetVersion.html" (dict "page" $page "base" true) -}} +{{- $disable := eq (index $page.Params "sidebar-menu") false -}} +{{- $vstate := partialCached "utilities/GetVersionedMenu.html" (dict "page" $page "version" $version) $page.Section $version $page.Kind $disable -}} + +{{- $pageAlertMsg := "" -}} +{{- $pageAlertURL := "" -}} +{{- if $vstate.isOlder -}} + {{- $pageAlertMsg = T "newerVersionAlert" site.Title -}} + {{- $pageAlertURL = or site.Params.docs.latestURL site.baseURL -}} +{{- end -}} {{/* Main code */}} {{- if and (not $args.err) $pageAlertMsg -}} diff --git a/layouts/_partials/assets/persona.html b/layouts/_partials/assets/persona.html index 24c4da5b9..34bcd86ab 100644 --- a/layouts/_partials/assets/persona.html +++ b/layouts/_partials/assets/persona.html @@ -72,6 +72,7 @@ {{ $illustration := "" }} {{- if $thumbnail -}} {{- $illustration = partial "assets/image.html" (dict + "page" (partial "utilities/OmitEmpty.html" $page) "src" $thumbnail "title" $title "ratio" "1x1" diff --git a/layouts/_partials/assets/section-title.html b/layouts/_partials/assets/section-title.html index 20461f143..c31fd2018 100644 --- a/layouts/_partials/assets/section-title.html +++ b/layouts/_partials/assets/section-title.html @@ -14,6 +14,19 @@ )}} {{ end }} +{{/* Resolve the intrinsic page; fall back to the global page for one release */}} +{{- $page := $args.page -}} +{{- if not $page -}} + {{- $noop := partial "utilities/LogWarn.html" (dict + "partial" "assets/section-title.html" + "warnid" "warn-missing-page-argument" + "msg" "Missing argument 'page', falling back to the global page context" + "details" (slice "Pass the rendering page explicitly; this fallback will be removed in a future release") + "file" page.File + ) -}} + {{- $page = page -}} +{{- end -}} + {{/* Initialize global arguments */}} {{- $breakpoint := partial "utilities/GetBreakpoint.html" -}} {{- $padding := partial "utilities/GetPadding.html" -}} @@ -27,27 +40,28 @@ {{- $title := $args.heading.title }} {{- $width := $args.heading.width | default 12 -}} {{- $width = cond (lt $width 12) (printf "col-12 col-%s-%d" $breakpoint.current $width) "" }} -{{- if and (not $preheading) $args.useSection }}{{ $preheading = page.CurrentSection.Name }}{{ end -}} +{{- if and (not $preheading) $args.useSection }}{{ $preheading = $page.CurrentSection.Name }}{{ end -}} {{- $justify := cond (eq $args.justify "start") "" (cond (eq $args.justify "end") "me-0" "mx-auto") -}} -{{ if and site.Params.main.titleCase (not $args.page.Params.exact) }} +{{ if and site.Params.main.titleCase (not $page.Params.exact) }} {{ $preheading = title $preheading }} {{ $title = title $title }} {{ end }} {{ define "_partials/assets/section-title-header.html" }} + {{- $page := .page }} {{ $headingStyle := .headingStyle }} {{ if (index . "use-title") }} - {{ $title := .title | page.RenderString }} + {{ $title := .title | $page.RenderString }} {{ $label := trim (replaceRE "\r\n?|\n" " " ($title | plainify)) " " }} -

- {{ .title | page.RenderString | safeHTML }} + {{ .title | $page.RenderString | safeHTML }}

{{ else }}
- {{ .title | page.RenderString | safeHTML }} + {{ .title | $page.RenderString | safeHTML }}
{{ end }} {{ end }} @@ -55,6 +69,7 @@ {{ $header := "" }} {{ if $title }} {{ $header = partial "assets/section-title-header.html" (dict + "page" $page "use-title" $args.useTitle "title" $title "headingStyle" $headingStyle @@ -66,7 +81,7 @@ {{ $links := "" }} {{ if $args.links }} {{ $links = partial "assets/links.html" (dict - "page" $args.page + "page" $page "links" $args.links "align" $args.heading.align "justify" $args.justify @@ -83,14 +98,14 @@
{{ with $preheading }}

- {{ . | page.RenderString | safeHTML }} + {{ . | $page.RenderString | safeHTML }}

{{ end }}
{{ $header }} {{ with $args.heading.content }} -
{{ . | page.RenderString | safeHTML }}
+
{{ . | $page.RenderString | safeHTML }}
{{ end }} {{ $links }}
@@ -101,11 +116,11 @@ {{ else }} {{ with $preheading }}

- {{ . | page.RenderString | safeHTML }} + {{ . | $page.RenderString | safeHTML }}

{{ end }} {{ $header }} - {{ with $args.heading.content }}
{{ . | page.RenderString | safeHTML }}
{{ end }} + {{ with $args.heading.content }}
{{ . | $page.RenderString | safeHTML }}
{{ end }} {{ $links }} {{ end }}
diff --git a/layouts/_partials/assets/sidebar.html b/layouts/_partials/assets/sidebar.html index 1815e8cad..7b148aff2 100644 --- a/layouts/_partials/assets/sidebar.html +++ b/layouts/_partials/assets/sidebar.html @@ -270,6 +270,7 @@
{{- with $logo -}} {{ partial "assets/image.html" (dict + "page" $args.page "src" . "loading" "eager" "title" site.Title @@ -280,6 +281,7 @@ {{- end -}} {{- with $logoCollapsed -}} {{ partial "assets/image.html" (dict + "page" $args.page "src" . "loading" "eager" "title" site.Title diff --git a/layouts/_partials/assets/timeline.html b/layouts/_partials/assets/timeline.html index cd7c43bdd..7948853f1 100644 --- a/layouts/_partials/assets/timeline.html +++ b/layouts/_partials/assets/timeline.html @@ -139,6 +139,7 @@ {{ $title := "" }} {{ if $args.heading }} {{ $title = partial "assets/section-title.html" (dict + "page" $page "heading" $args.heading "use-title" $args.useTitle "size" $args.size diff --git a/layouts/_partials/assets/toc-parse-content.html b/layouts/_partials/assets/toc-parse-content.html index 100abfb29..027d30af5 100644 --- a/layouts/_partials/assets/toc-parse-content.html +++ b/layouts/_partials/assets/toc-parse-content.html @@ -52,13 +52,9 @@ {{- /* Render */}} {{- if .Site.Params.navigation.toc }} - {{- /* Check for custom headings in Page.Store or Page.Params, otherwise use Page.Fragments */}} - {{- $customHeadings := .Page.Store.Get "Headings" }} - {{- $customHeadingsMap := .Page.Store.Get "HeadingsMap" }} - {{- if not $customHeadings }} - {{- $customHeadings = .Page.Params.Headings }} - {{- $customHeadingsMap = .Page.Params.HeadingsMap }} - {{- end }} + {{- /* Check for custom headings in Page.Params, otherwise use Page.Fragments */}} + {{- $customHeadings := .Page.Params.Headings }} + {{- $customHeadingsMap := .Page.Params.HeadingsMap }} {{- $fragments := cond $customHeadings (dict "Headings" $customHeadings "HeadingsMap" $customHeadingsMap) .Page.Fragments }} diff --git a/layouts/_partials/page/articles.html b/layouts/_partials/page/articles.html index 363f303c9..1702c0fc3 100644 --- a/layouts/_partials/page/articles.html +++ b/layouts/_partials/page/articles.html @@ -6,6 +6,7 @@ {{ partial "assets/breadcrumb.html" (dict "page" .) }} {{ end }} {{ partial "assets/section-title.html" (dict + "page" . "heading" (dict "title" .Title "content" .Description @@ -45,6 +46,7 @@ {{ range $pages }}
{{ partial "assets/card.html" (dict + "page" $ "title" .Title "thumbnail" .Thumbnail "description" .Description @@ -61,6 +63,7 @@ {{ range (.Paginate $pages).Pages }}
{{ partial "assets/card.html" (dict + "page" $ "path" .RelPermalink "class" $class "padding" $cardPadding diff --git a/layouts/_partials/page/thumbnail.html b/layouts/_partials/page/thumbnail.html index f833f7ee9..5ad73f72b 100644 --- a/layouts/_partials/page/thumbnail.html +++ b/layouts/_partials/page/thumbnail.html @@ -37,6 +37,7 @@ {{ if $thumbnail -}} {{- partial "assets/image.html" (dict + "page" $page "src" $thumbnail "anchor" (partial "utilities/OmitEmpty.html" $anchor) "ratio" $ratio diff --git a/layouts/_partials/utilities/GetIllustration.html b/layouts/_partials/utilities/GetIllustration.html index cf6fe9bba..50dd6f345 100644 --- a/layouts/_partials/utilities/GetIllustration.html +++ b/layouts/_partials/utilities/GetIllustration.html @@ -16,6 +16,7 @@ {{ if reflect.IsMap $item.Params.Thumbnail }}{{ $thumbnail = $item.Params.Thumbnail.url }}{{ else }}{{ $thumbnail = $item.Params.Thumbnail }}{{ end }} {{- if $thumbnail }} {{ $illustration = partial "assets/image.html" (dict + "page" $item "src" $thumbnail "ratio" "16x9" "wrapper" $style diff --git a/layouts/_partials/utilities/GetVersionedMenu.html b/layouts/_partials/utilities/GetVersionedMenu.html new file mode 100644 index 000000000..bbe18f46b --- /dev/null +++ b/layouts/_partials/utilities/GetVersionedMenu.html @@ -0,0 +1,42 @@ +{{/* + Copyright © 2026 The Hinode Team / Mark Dumay. All rights reserved. + Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file. + Visit gethinode.com/license for more details. + + Computes the version-aware sidebar state of a page: the docs version (base label), the + matching sidebar menu, and whether that version is older than the site's latest release. + This is the same logic baseof.html uses to seed the "version", "sidebar", "pageAlertMsg", + and "pageAlertURL" scratch values, extracted so layout and shortcode paths can share it + without reading the page's scratch (which is unreliable outside the page's own render). + + The result is a pure function of the page's section, docs version, kind, and "sidebar-menu" + page parameter. Callers on a hot path should invoke it as: + + partialCached "utilities/GetVersionedMenu.html" (dict "page" $page "version" $version) + $page.Section $version $page.Kind $disable + + with $version obtained from "utilities/GetVersion.html" (cheap) and $disable reflecting the + page's "sidebar-menu" parameter. baseof.html deliberately calls it uncached so the + "sidebarFilename" diagnostic that GetMenu records on the page's scratch keeps landing on + every page. + + Arguments: + - page: context of the intrinsic page (required) + - version: precomputed base version of the page (optional) + + Returns a dict with the keys "version" (string), "menu" (menu data or ""), and "isOlder" + (bool). +*/}} + +{{- $page := .page -}} +{{- $version := or .version (partial "utilities/GetVersion.html" (dict "page" $page "base" true)) -}} +{{- $menu := partial "utilities/GetMenu" (dict "page" $page "version" $version) -}} + +{{- $isOlder := false -}} +{{- if and site.Params.docs.checkVersion $version -}} + {{- if ne $version "latest" -}} + {{- $isOlder = partial "utilities/IsOlder" (dict "current" $version) -}} + {{- end -}} +{{- end -}} + +{{- return (dict "version" $version "menu" $menu "isOlder" $isOlder) -}} diff --git a/layouts/_shortcodes/card.html b/layouts/_shortcodes/card.html index 90b3dbe76..cbfb2f9d3 100644 --- a/layouts/_shortcodes/card.html +++ b/layouts/_shortcodes/card.html @@ -73,6 +73,7 @@ {{ if not $error -}} {{/* Render card */}} {{- $output := partial "assets/card.html" (dict + "page" $page "path" $path "href" $args.href "title" $title diff --git a/layouts/_shortcodes/table.html b/layouts/_shortcodes/table.html index 19a8ee045..756d42ce5 100644 --- a/layouts/_shortcodes/table.html +++ b/layouts/_shortcodes/table.html @@ -41,7 +41,10 @@ {{ $page := .Page }} {{ $filtered := gt (len (findRE `[^,\s]` (printf "%v" (or $args.filter "")) 1)) 0 }} {{ if or $args.sortable $args.paginate $args.searchable $filtered }} - {{ with $page.Scratch.Get "modules" }} + {{- /* Mirror the cache shape of baseof.html: page context, no variant key, so both share a + single cached entry per language. InitModules needs a page context (it calls .IsPage + and .Site), which rules out `site` here. */}} + {{ with partialCached "utilities/InitModules.html" $page }} {{ if in (.optional | default slice) "simple-datatables" }} {{ $pageModules := slice | append $page.Params.modules }} {{ if not (in $pageModules "simple-datatables") }} diff --git a/layouts/baseof.html b/layouts/baseof.html index 476d7ba35..cf508720a 100644 --- a/layouts/baseof.html +++ b/layouts/baseof.html @@ -1,16 +1,15 @@ -{{- /* Set version-aware sidebar menu */ -}} -{{- $version := partial "utilities/GetVersion.html" (dict "page" . "base" true) -}} +{{- /* Set version-aware sidebar menu. The helper is called uncached on purpose: GetMenu + records the "sidebarFilename" diagnostic on the page's scratch, which should land on + every page. The scratch seeds below remain for downstream readers. */ -}} +{{- $vstate := partial "utilities/GetVersionedMenu.html" (dict "page" .) -}} +{{- $version := $vstate.version -}} {{- $.Scratch.Set "version" $version -}} -{{ with partial "utilities/GetMenu" (dict "page" . "version" $version) }}{{ $.Scratch.Set "sidebar" . }}{{ end }} +{{ with $vstate.menu }}{{ $.Scratch.Set "sidebar" . }}{{ end }} {{- /* Validate if current version is latest */ -}} -{{- if and site.Params.docs.checkVersion $version -}} - {{- if ne $version "latest" -}} - {{- if partial "utilities/IsOlder" (dict "current" $version) -}} - {{- $.Scratch.Set "pageAlertMsg" (T "newerVersionAlert" site.Title) -}} - {{- $.Scratch.Set "pageAlertURL" (or site.Params.docs.latestURL site.baseURL) -}} - {{- end -}} - {{- end -}} +{{- if $vstate.isOlder -}} + {{- $.Scratch.Set "pageAlertMsg" (T "newerVersionAlert" site.Title) -}} + {{- $.Scratch.Set "pageAlertURL" (or site.Params.docs.latestURL site.baseURL) -}} {{- end -}} {{- /* Initialize module configuration */ -}} diff --git a/layouts/toc.html b/layouts/toc.html index be41cbdc1..1705d6c0e 100644 --- a/layouts/toc.html +++ b/layouts/toc.html @@ -5,7 +5,8 @@
{{ if $download }}
- {{ partial "assets/download.html" (dict + {{ partial "assets/download.html" (dict + "page" . "download" $download "outline" true "button-size" "sm"