Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions data/structures/card.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions data/structures/download.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
comment: Generates a download button or link.
group: partial
arguments:
page:
optional: true
download:
title:
class:
Expand Down
2 changes: 2 additions & 0 deletions data/structures/image-adapter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions data/structures/image-set.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ comment: >-
hook, including transform, format, and anchor options.
group: partial
arguments:
page:
optional: true
src:
img:
absolute-url:
Expand Down
2 changes: 2 additions & 0 deletions data/structures/section-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ comment: >-
layout options.
group: partial
arguments:
page:
optional: true
heading:
links:
color:
Expand Down
5 changes: 4 additions & 1 deletion exampleSite/config/_default/hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion exampleSite/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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
)
2 changes: 0 additions & 2 deletions exampleSite/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,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=
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,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=
Expand Down
15 changes: 14 additions & 1 deletion layouts/_partials/assets/adapters/hugo.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 */}}
Expand Down
3 changes: 2 additions & 1 deletion layouts/_partials/assets/card-group.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 */}}
Expand Down Expand Up @@ -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)
Expand Down
22 changes: 20 additions & 2 deletions layouts/_partials/assets/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand All @@ -38,7 +39,7 @@
<a href="{{ $href }}" class="{{ if $color }}link-bg-{{ $color }}{{ else }}card-body-link{{ end }} stretched-link {{ $class }}">
{{ if or $title $links }}
<p class="card-title {{ $fs }}">
{{- with $title }}{{ . | page.RenderString }}{{ end }}
{{- with $title }}{{ . | $page.RenderString }}{{ end }}
{{ with $links }}{{ partial "inline/card-icons.html" (dict "links" .) }}{{ end -}}
{{- with $linkIcon -}}<span class="card-link-icon">{{- partial "assets/icon.html" (dict "icon" . "spacing" false) -}}</span>{{- end -}}
</p>
Expand All @@ -53,7 +54,7 @@
<div{{ with $class }} class="{{ . }}"{{ end }}>
{{ if or $title $links }}
<p class="card-title {{ $fs }}">
{{- with $title }}{{ . | page.RenderString }}{{ end }}
{{- with $title }}{{ . | $page.RenderString }}{{ end }}
{{ with $links }}{{ partial "inline/card-icons.html" (dict "links" .) }}{{ end -}}
</p>
{{ end -}}
Expand Down Expand Up @@ -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 }}
Expand All @@ -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
Expand Down Expand Up @@ -246,6 +262,7 @@
</div>
{{ end }}
{{- partial "inline/card-body.html" (dict
"page" $renderPage
"title" (cond $minimal "" $title)
"href" $href
"color" $args.color
Expand Down Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion layouts/_partials/assets/download.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand Down
1 change: 1 addition & 0 deletions layouts/_partials/assets/featured-illustration.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions layouts/_partials/assets/helpers/image-dimension.html
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion layouts/_partials/assets/helpers/image-set.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion layouts/_partials/assets/helpers/navbar-item.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
17 changes: 15 additions & 2 deletions layouts/_partials/assets/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,34 @@
{{- $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 -}}

{{/* Main code */}}
{{- $params := dict -}}
{{- $params = merge $params (dict
"page" $args.page
"page" $page
"ratio" $args.ratio
"portrait" $args.portrait
"image-width" $args.imageWidth
Expand Down
23 changes: 19 additions & 4 deletions layouts/_partials/assets/links.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 := partialCached "utilities/GetBreakpoint.html" site -}}
{{- $padding := partial "utilities/GetPadding.html" -}}

{{- define "_partials/links-content.html" -}}
{{- $page := .page -}}
{{ $links := .links }}
{{ $justify := .justify }}
{{ $type := .type }}
Expand All @@ -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 }}
Expand All @@ -54,7 +68,8 @@
{{ if (eq $li true) }}<div>{{ end }}

{{ if .download }}
{{ partial "assets/download.html" (dict
{{ partial "assets/download.html" (dict
"page" $page
"download" .download
"title" $title
"icon" .icon
Expand Down Expand Up @@ -96,9 +111,9 @@
{{ end }}

<div class="hstack d-none d-{{ $breakpoint.current }}-block {{ if gt (len $args.links) 1 }} gap-5{{ end }} justify-content-{{ $args.align }} pt-{{ $padding.y }}">
{{ 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) }}
</div>

<div class="d-{{ $breakpoint.current }}-none pt-{{ $padding.y }}">
{{ 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) }}
</div>
7 changes: 5 additions & 2 deletions layouts/_partials/assets/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -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" -}}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")) -}}
<div class="d-flex align-items-center">
{{- if $sidebar -}}
Expand Down
Loading