-
+
+
{{ partial "assets/icon.html" (dict "icon" "fa face-frown fa-10x") }}
404
{{ T "pageNotFoundTitle" }}
- {{- $home := printf "
%s" $base (T "pageNotFoundHome") -}}
+ {{- $home := printf `
%s` $base (T "pageNotFoundHome") -}}
{{ T "pageNotFound" $home | safeHTML }}
-
+
{{ end }}
diff --git a/layouts/_markup/render-image.html b/layouts/_markup/render-image.html
index 4e466981..578f32ef 100644
--- a/layouts/_markup/render-image.html
+++ b/layouts/_markup/render-image.html
@@ -1,15 +1,15 @@
{{ partial "assets/image.html" (dict
- "url" .Destination
- "page" .Page
- "caption" .Title
- "title" .Text
- "anchor" .Attributes.anchor
- "class" .Attributes.class
+ "src" .Destination
+ "page" .Page
+ "caption" .Title
+ "title" .Text
+ "anchor" .Attributes.anchor
+ "class" .Attributes.class
"figclass" .Attributes.figclass
- "loading" .Attributes.loading
- "mode" .Attributes.mode
- "plain" .Attributes.plain
+ "loading" .Attributes.loading
+ "mode" .Attributes.mode
+ "plain" .Attributes.plain
"portrait" .Attributes.portrait
- "ratio" .Attributes.ratio
- "wrapper" .Attributes.wrapper
+ "ratio" .Attributes.ratio
+ "wrapper" .Attributes.wrapper
) }}
diff --git a/layouts/_markup/render-link.html b/layouts/_markup/render-link.html
index 720d9d03..cd5ef1a0 100644
--- a/layouts/_markup/render-link.html
+++ b/layouts/_markup/render-link.html
@@ -7,9 +7,9 @@
{{ errorf "Missing markdown link destination, see '%s'" .Page.File.Path }}
{{ else }}
{{ partial "assets/link.html" (dict
- "destination" .Destination
- "page" .Page
- "text" .Text
+ "href" .Destination
+ "page" .Page
+ "text" .Text
"title" .Title
) }}
{{- end }}
\ No newline at end of file
diff --git a/layouts/_partials/assets/adapters/cloudinary.html b/layouts/_partials/assets/adapters/cloudinary.html
index 5f989f9b..061ee537 100644
--- a/layouts/_partials/assets/adapters/cloudinary.html
+++ b/layouts/_partials/assets/adapters/cloudinary.html
@@ -7,39 +7,54 @@
{{ $error := false }}
{{ $anchorMap := dict
- "TopLeft" "north_west"
- "Top" "north"
- "TopRight" "north_east"
- "Left" "west"
- "Center" "center"
- "Right" "east"
- "BottomLeft" "south_west"
- "Bottom" "south"
+ "TopLeft" "north_west"
+ "Top" "north"
+ "TopRight" "north_east"
+ "Left" "west"
+ "Center" "center"
+ "Right" "east"
+ "BottomLeft" "south_west"
+ "Bottom" "south"
"BottomRight" "south_east"
- "Smart" "auto"
+ "Smart" "auto"
}}
-{{/* Validate arguments */}}
-{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "image-adapter" "args" . "group" "partial") }}
- {{ errorf "partial [assets/adapter/cloudinary.html] - Invalid arguments" -}}
- {{ $error = true }}
+{{/* Initialize arguments */}}
+{{ $args := partial "utilities/InitArgs.html" (dict "structure" "image-adapter" "args" . "group" "partial") }}
+{{ if or $args.err $args.warnmsg }}
+ {{ partial (cond $args.err "utilities/LogErr.html" "utilities/LogWarn.html") (dict
+ "partial" "assets/adapter/cloudinary.html"
+ "msg" "Invalid arguments"
+ "details" ($args.errmsg | append $args.warnmsg)
+ "file" page.File
+ )}}
+ {{ $error = $args.err }}
{{ end }}
{{/* Initialize arguments */}}
-{{ $host := .host }}
-{{ $dir := .dir }}
-{{ $file := .file }}
-{{ $format := .format }}
-{{ $transform := .transform }}
-{{ $height := .height }}
-{{ $width := .width }}
-{{ $anchor := "" }}
-{{ with .anchor }}{{ $anchor = index $anchorMap . }}{{ end }}
+{{ $file := or $args.urlFile $args.file }}
+{{ if not $file }}
+ {{ partial "utilities/LogErr.html" (dict
+ "partial" "assets/adapter/cloudinary.html"
+ "msg" "Invalid arguments"
+ "details" slice "argument 'url-file': expected value"
+ "file" page.File
+ )}}
+ {{ $error = true }}
+{{ end }}
+
+{{ $dir := or $args.urlDir $args.dir }}
+{{ $host := or $args.urlHost $args.host }}
+{{ $height := or $args.imageHeight $args.height -}}
+{{ $width := or $args.imageWidth $args.width -}}
+{{ $transform := $args.transform }}
{{ if eq $transform "fill" }}{{ $transform = "c_fill" }}{{ else }}{{ $transform = "c_fit" }}{{ end }}
+{{ $anchor := "" }}
+{{ with $args.anchor }}{{ $anchor = index $anchorMap . }}{{ end }}
{{ $element := "" }}
{{/* Split path between upload dir and sub dir */}}
-{{ $dir = path.Clean (trim .dir "/") }}
+{{ $dir = path.Clean (trim $dir "/") }}
{{ $api := "image/upload" }}
{{/* Define the account, optional API segment, and directory */}}
@@ -55,9 +70,9 @@
{{/* Generate image URL */}}
{{ if not $error }}
- {{ if $format }}
+ {{ if $args.format }}
{{ $operation = printf "%s,h_%d,w_%d" $transform $height $width }}
- {{ $file = printf "%s.%s" (strings.TrimSuffix (path.Ext $file) $file) $format }}
+ {{ $file = printf "%s.%s" (strings.TrimSuffix (path.Ext $file) $file) $args.format }}
{{ else }}
{{ $operation = printf "f_auto,%s,h_%d,w_%d" $transform $height $width }}
{{ end }}
diff --git a/layouts/_partials/assets/adapters/hugo.html b/layouts/_partials/assets/adapters/hugo.html
index 6a4c2f56..e5cf71ff 100644
--- a/layouts/_partials/assets/adapters/hugo.html
+++ b/layouts/_partials/assets/adapters/hugo.html
@@ -6,31 +6,42 @@
{{ $error := false }}
-{{/* Validate arguments */}}
-{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "image-adapter" "args" . "group" "partial") }}
- {{ errorf "partial [assets/adapter/hugo.html] - Invalid arguments" -}}
- {{ $error = true }}
+{{/* Initialize arguments */}}
+{{ $args := partial "utilities/InitArgs.html" (dict "structure" "image-adapter" "args" . "group" "partial") }}
+{{ if or $args.err $args.warnmsg }}
+ {{ partial (cond $args.err "utilities/LogErr.html" "utilities/LogWarn.html") (dict
+ "partial" "assets/adapter/hugo.html"
+ "msg" "Invalid arguments"
+ "details" ($args.errmsg | append $args.warnmsg)
+ "file" page.File
+ )}}
+ {{ $error = $args.err }}
{{ end }}
{{/* Initialize arguments */}}
-{{ $host := .host }}
-{{ $dir := .dir }}
-{{ $file := .file }}
-{{ $img := .img }}
-{{ $transform := .transform }}
-{{ $height := .height }}
-{{ $width := .width }}
-{{ $anchor := .anchor | default "" }}
+{{ $img := $args.img }}
{{ $element := "" }}
-{{ $absoluteURL := .absoluteURL }}
+{{ $file := or $args.urlFile $args.file }}
+{{ if not $file }}
+ {{ partial "utilities/LogErr.html" (dict
+ "partial" "assets/adapter/hugo.html"
+ "msg" "Invalid arguments"
+ "details" slice "argument 'url-file': expected value"
+ "file" page.File
+ )}}
+ {{ $error = true }}
+{{ end }}
+{{ $dir := or $args.urlDir $args.dir }}
+{{ $host := or $args.urlHost $args.host }}
{{ $url := partial "utilities/URLJoin.html" (dict "elements" (slice $dir $file)) }}
{{ if $host }}
{{ $url = partial "utilities/URLJoin.html" (dict "elements" (slice "https://" $host $url)) }}
{{ end }}
+{{ $height := or $args.imageHeight $args.height -}}
+{{ $width := or $args.imageWidth $args.width -}}
{{/* Initialize image if needed, do not raise additional warnings */}}
-{{ $format := .format | default "webp" }}
-{{ if and (not $img) (ne $format "svg") }}
+{{ if and (not $img) (ne $args.format "svg") }}
{{- $res := partial "utilities/GetImage.html" (dict "url" $url "page" page) -}}
{{ if $res }}
{{ $img = $res.resource }}
@@ -46,22 +57,22 @@
{{/* Process image and generate image URL */}}
{{ if not $error }}
{{ $scaled := "" }}
- {{ if eq $transform "fill" }}
- {{- $scaled = $img.Fill (printf "%dx%d %s %s" $width $height $anchor $format) -}}
+ {{ if eq $args.transform "fill" }}
+ {{- $scaled = $img.Fill (printf "%dx%d %s %s" $width $height $args.anchor $args.format) -}}
{{ else }}
- {{- $scaled = $img.Fit (printf "%dx%d %s" $width $height $format) -}}
+ {{- $scaled = $img.Fit (printf "%dx%d %s" $width $height $args.format) -}}
{{ end }}
{{- $clean := path.Ext $img.RelPermalink -}}
{{ $destination := "" }}
- {{ if $anchor }}
- {{ $destination = printf "-%dx%d-%s.%s" $width $height (lower $anchor) $format }}
+ {{ if $args.anchor }}
+ {{ $destination = printf "-%dx%d-%s.%s" $width $height (lower $args.anchor) $args.format }}
{{ else }}
- {{ $destination = printf "-%dx%d.%s" $width $height $format }}
+ {{ $destination = printf "-%dx%d.%s" $width $height $args.format }}
{{ end }}
{{- $scaled = $scaled | resources.Copy (replace $img.RelPermalink $clean $destination) -}}
- {{- if $absoluteURL -}}
+ {{- if or $args.absoluteUrl $args.absoluteURL -}}
{{- $element = $scaled.Permalink -}}
{{- else -}}
{{- $element = $scaled.RelPermalink -}}
diff --git a/layouts/_partials/assets/adapters/imagekit-rewrite.html b/layouts/_partials/assets/adapters/imagekit-rewrite.html
index f0454ab2..11c0dd49 100644
--- a/layouts/_partials/assets/adapters/imagekit-rewrite.html
+++ b/layouts/_partials/assets/adapters/imagekit-rewrite.html
@@ -6,23 +6,37 @@
{{ $error := false }}
-{{/* Validate arguments */}}
-{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "image-adapter-rewrite" "args" . "group" "partial") }}
- {{ errorf "partial [assets/adapter/imagekit-rewrite.html] - Invalid arguments" -}}
- {{ $error = true }}
+{{/* Initialize arguments */}}
+{{ $args := partial "utilities/InitArgs.html" (dict "structure" "image-adapter-rewrite" "args" . "group" "partial") }}
+{{ if or $args.err $args.warnmsg }}
+ {{ partial (cond $args.err "utilities/LogErr.html" "utilities/LogWarn.html") (dict
+ "partial" "assets/adapter/imagekit-rewrite.html"
+ "msg" "Invalid arguments"
+ "details" ($args.errmsg | append $args.warnmsg)
+ "file" page.File
+ )}}
+ {{ $error = $args.err }}
{{ end }}
-{{/* Initialize arguments */}}
-{{ $account := .account }}
-{{ $container := trim .container "/" }}
-{{ $host := .host }}
-{{ $dir := .dir }}
-{{ $file := .file }}
+{{/* Initialize local arguments */}}
+{{ $container := trim $args.container "/" }}
+{{ $file := or $args.urlFile $args.file }}
+{{ if not $file }}
+ {{ partial "utilities/LogErr.html" (dict
+ "partial" "assets/adapter/imagekit-rewrite.html"
+ "msg" "Invalid arguments"
+ "details" slice "argument 'url-file': expected value"
+ "file" page.File
+ )}}
+ {{ $error = true }}
+{{ end }}
+{{ $dir := or $args.urlDir $args.dir }}
+{{ $host := or $args.urlHost $args.host }}
{{ $element := "" }}
{{ with $container }}{{ $dir = strings.TrimPrefix (printf "/%s" .) $dir }}{{ end }}
{{ if ne $host "ik.imagekit.io" }}
- {{ $element = partial "utilities/URLJoin.html" (dict "elements" (slice "https://ik.imagekit.io" $account $dir $file)) }}
+ {{ $element = partial "utilities/URLJoin.html" (dict "elements" (slice "https://ik.imagekit.io" $args.account $dir $file)) }}
{{ else }}
{{ $element = partial "utilities/URLJoin.html" (dict "elements" (slice "https://" $host $dir $file)) }}
{{ end }}
diff --git a/layouts/_partials/assets/adapters/imagekit.html b/layouts/_partials/assets/adapters/imagekit.html
index 9e23a43e..b97e8bb2 100644
--- a/layouts/_partials/assets/adapters/imagekit.html
+++ b/layouts/_partials/assets/adapters/imagekit.html
@@ -7,36 +7,51 @@
{{ $error := false }}
{{ $anchorMap := dict
- "TopLeft" "top_left"
- "Top" "top"
- "TopRight" "top_right"
- "Left" "left"
- "Center" "center"
- "Right" "right"
- "BottomLeft" "bottom_left"
- "Bottom" "bottom"
+ "TopLeft" "top_left"
+ "Top" "top"
+ "TopRight" "top_right"
+ "Left" "left"
+ "Center" "center"
+ "Right" "right"
+ "BottomLeft" "bottom_left"
+ "Bottom" "bottom"
"BottomRight" "bottom_right"
- "Smart" "auto"
+ "Smart" "auto"
}}
-{{/* Validate arguments */}}
-{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "image-adapter" "args" . "group" "partial") }}
- {{ errorf "partial [assets/adapter/imagekit.html] - Invalid arguments" -}}
- {{ $error = true }}
+{{/* Initialize arguments */}}
+{{ $args := partial "utilities/InitArgs.html" (dict "structure" "image-adapter" "args" . "group" "partial") }}
+{{ if or $args.err $args.warnmsg }}
+ {{ partial (cond $args.err "utilities/LogErr.html" "utilities/LogWarn.html") (dict
+ "partial" "assets/adapter/imagekit.html"
+ "msg" "Invalid arguments"
+ "details" ($args.errmsg | append $args.warnmsg)
+ "file" page.File
+ )}}
+ {{ $error = $args.err }}
{{ end }}
{{/* Initialize arguments */}}
-{{ $host := .host }}
-{{ $dir := .dir }}
-{{ $file := .file }}
-{{ $format := .format }}
-{{ $transform := .transform }}
-{{ $height := .height }}
-{{ $width := .width }}
+{{ $file := or $args.urlFile $args.file }}
+{{ if not $file }}
+ {{ partial "utilities/LogErr.html" (dict
+ "partial" "assets/adapter/imagekit.html"
+ "msg" "Invalid arguments"
+ "details" slice "argument 'url-file': expected value"
+ "file" page.File
+ )}}
+ {{ $error = true }}
+{{ end }}
+{{ $dir := or $args.urlDir $args.dir }}
+{{ $host := or $args.urlHost $args.host }}
+{{ $format := $args.format }}
+{{ $transform := $args.transform }}
{{ $anchor := "" }}
-{{ with .anchor }}{{ $anchor = index $anchorMap . }}{{ end }}
+{{ with $args.anchor }}{{ $anchor = index $anchorMap . }}{{ end }}
{{ if eq $transform "fill" }}{{ $transform = "c-maintain_ratio" }}{{ else }}{{ $transform = "c-at_max" }}{{ end }}
{{ $element := "" }}
+{{ $height := or $args.imageHeight $args.height -}}
+{{ $width := or $args.imageWidth $args.width -}}
{{/* Validate image format is supported */}}
{{ if and $format (not (in (slice "jpg" "jpeg" "webp" "avif" "png") $format)) }}
diff --git a/layouts/_partials/assets/adapters/imgix.html b/layouts/_partials/assets/adapters/imgix.html
index 8df0462c..761effbd 100644
--- a/layouts/_partials/assets/adapters/imgix.html
+++ b/layouts/_partials/assets/adapters/imgix.html
@@ -4,39 +4,51 @@
Visit gethinode.com/license for more details.
*/}}
-{{ $error := false }}
-
{{ $anchorMap := dict
- "TopLeft" "top,left"
- "Top" "top"
- "TopRight" "top,right"
- "Left" "left"
- "Center" "center"
- "Right" "right"
- "BottomLeft" "bottom,left"
- "Bottom" "bottom"
+ "TopLeft" "top,left"
+ "Top" "top"
+ "TopRight" "top,right"
+ "Left" "left"
+ "Center" "center"
+ "Right" "right"
+ "BottomLeft" "bottom,left"
+ "Bottom" "bottom"
"BottomRight" "bottom,right"
- "Smart" "faces,edges,center"
+ "Smart" "faces,edges,center"
}}
-{{/* Validate arguments */}}
-{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "image-adapter" "args" . "group" "partial") }}
- {{ errorf "partial [assets/adapter/imgix.html] - Invalid arguments" -}}
- {{ $error = true }}
+{{/* Initialize arguments */}}
+{{ $args := partial "utilities/InitArgs.html" (dict "structure" "image-adapter" "args" . "group" "partial") }}
+{{ if or $args.err $args.warnmsg }}
+ {{ partial (cond $args.err "utilities/LogErr.html" "utilities/LogWarn.html") (dict
+ "partial" "assets/adapter/imgix.html"
+ "msg" "Invalid arguments"
+ "details" ($args.errmsg | append $args.warnmsg)
+ "file" page.File
+ )}}
{{ end }}
-{{/* Initialize arguments */}}
-{{ $host := .host }}
-{{ $dir := .dir }}
-{{ $file := .file }}
-{{ $format := .format }}
-{{ $transform := .transform }}
-{{ $height := .height }}
-{{ $width := .width }}
+{{/* Initialize local arguments */}}
+{{ $file := or $args.urlFile $args.file }}
+{{ if not $file }}
+ {{ partial "utilities/LogErr.html" (dict
+ "partial" "assets/adapter/imgix.html"
+ "msg" "Invalid arguments"
+ "details" slice "argument 'url-file': expected value"
+ "file" page.File
+ )}}
+ {{ $error = true }}
+{{ end }}
+{{ $dir := or $args.urlDir $args.dir }}
+{{ $host := or $args.urlHost $args.host }}
+{{ $format := $args.format }}
+{{ $transform := $args.transform }}
{{ $anchor := "" }}
-{{ with .anchor }}{{ $anchor = index $anchorMap . }}{{ end }}
+{{ with $args.anchor }}{{ $anchor = index $anchorMap . }}{{ end }}
{{ if eq $transform "fill" }}{{ $transform = "crop" }}{{ else }}{{ $transform = "max" }}{{ end }}
{{ $element := "" }}
+{{ $height := or $args.imageHeight $args.height -}}
+{{ $width := or $args.imageWidth $args.width -}}
{{/* Validate image format is supported */}}
{{ if and $format (not (in (slice "avif" "gif" "jp2" "jpg" "json" "jxr" "pjpg" "mp4" "png" "png8" "png32" "webm" "webp" "blurhash") $format)) }}
@@ -45,7 +57,7 @@
{{ end }}
{{/* Generate image URL */}}
-{{ if not $error }}
+{{ if not $args.err }}
{{ $operation := "" }}
{{ if $format }}
{{ $operation = printf "fm=%s&fit=%s&h=%d&w=%d" $format $transform $height $width }}
@@ -55,7 +67,8 @@
{{ with $anchor }}
{{ $operation = printf "%s&crop=%s" $operation . }}
{{ end }}
- {{- $element = printf "%s?%s" (partial "utilities/URLJoin.html" (dict "elements" (slice "https://" $host $dir $file))) $operation -}}
+ {{- $url := partial "utilities/URLJoin.html" (dict "elements" (slice "https://" $host $dir $file)) }}
+ {{- $element = printf "%s?%s" $url $operation -}}
{{ end }}
{{ return $element }}
diff --git a/layouts/_partials/assets/breadcrumb.html b/layouts/_partials/assets/breadcrumb.html
index 6b5dcf81..2bfe8dd7 100644
--- a/layouts/_partials/assets/breadcrumb.html
+++ b/layouts/_partials/assets/breadcrumb.html
@@ -7,7 +7,7 @@
{{ $error := false }}
{{/* Limits a title to a maximum of 33 runes, adds a "..." suffix otherwise */}}
-{{ define "partials/inline/short-title.html" }}
+{{ define "_partials/inline/short-title.html" }}
{{- $title := . -}}
{{ if gt (strings.RuneCount $title) 33 }}
{{ $title = print (substr $title 0 30) "..." }}
@@ -16,19 +16,24 @@
{{ return $title }}
{{ end }}
-{{/* Validate arguments */}}
-{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "breadcrumb" "args" . "group" "partial") }}
- {{- errorf "partial [assets/breadcrumb.html] - Invalid arguments" -}}
- {{ $error = true }}
+{{/* Initialize arguments */}}
+{{ $args := partial "utilities/InitArgs.html" (dict "structure" "breadcrumb" "args" . "group" "partial") }}
+{{ if or $args.err $args.warnmsg }}
+ {{ partial (cond $args.err "utilities/LogErr.html" "utilities/LogWarn.html") (dict
+ "partial" "assets/breadcrumb.html"
+ "msg" "Invalid arguments"
+ "details" ($args.errmsg | append $args.warnmsg)
+ "file" page.File
+ )}}
+ {{ $error = $args.err }}
{{ end }}
-{{/* Initialize arguments */}}
-{{- $page := .page -}}
-{{- $breakpoint := $page.Scratch.Get "breakpoint" -}}
+{{/* Initialize local arguments */}}
+{{- $breakpoint := $args.page.Scratch.Get "breakpoint" -}}
{{/* Include breadcrumb items that have both a title and address */}}
{{ $items := slice }}
-{{- range $index, $item := $page.Ancestors.Reverse -}}
+{{- range $index, $item := $args.page.Ancestors.Reverse -}}
{{- $title := .LinkTitle -}}
{{- if .IsHome }}{{ $title = T "home" }}{{ end -}}
{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
@@ -63,7 +68,7 @@
{{ $title }}
{{- end -}}
- {{ $title := $page.LinkTitle }}
+ {{ $title := $args.page.LinkTitle }}
{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
{{ $title }}
diff --git a/layouts/_partials/assets/button.html b/layouts/_partials/assets/button.html
index c403a918..091a550b 100644
--- a/layouts/_partials/assets/button.html
+++ b/layouts/_partials/assets/button.html
@@ -6,60 +6,58 @@
{{ $error := false }}
-{{/* Validate arguments */}}
-{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "button" "args" . "group" "partial") }}
- {{- errorf "partial [assets/button.html] - Invalid arguments" -}}
- {{ $error = true }}
+{{/* Initialize arguments */}}
+{{ $args := partial "utilities/InitArgs.html" (dict "structure" "button" "args" . "group" "partial")}}
+{{ if or $args.err $args.warnmsg }}
+ {{ partial (cond $args.err "utilities/LogErr.html" "utilities/LogWarn.html") (dict
+ "partial" "assets/button.html"
+ "msg" "Invalid arguments"
+ "details" ($args.errmsg | append $args.warnmsg)
+ "file" page.File
+ )}}
+ {{ $error = $args.err }}
{{ end }}
-{{/* Initialize arguments */}}
-{{- $title := trim .title " \r\n" -}}
-{{- $icon := .icon }}
-{{- if not (or $title $icon) -}}
+{{/* Initialize local arguments */}}
+{{- $title := trim $args.title " \r\n" -}}
+{{- if not (or $title $args.icon) -}}
{{- warnf "partial [assets/button.html] - Missing element title or icon" -}}
{{ $title = T "linkPlaceholder" }}
{{- end -}}
-
-{{- $id := .id }}
-{{- $state := .state | default "enabled" -}}
-{{- $size := .size | default "md" -}}
-{{- $color := .color | default "primary" -}}
-{{- $outline := .outline | default false -}}
-{{- $badge := .badge | default "" -}}
-{{- $label := .label | default $title -}}
+{{- $label := $args.label | default $title -}}
{{- $tooltip := "" -}}
+{{ $state := or $args.buttonState $args.state }}
{{- if not (strings.HasSuffix $state "active") -}}
- {{- with .tooltip }}{{ $tooltip = . }}{{ end -}}
+ {{- with $args.tooltip }}{{ $tooltip = . }}{{ end -}}
{{- end -}}
{{- $href := .href -}}
-{{- $collapse := "" -}}
+
+{{ $linkType := or $args.linkType $args.type }}
+{{ $buttonSize := or $args.buttonSize $args.size }}
+{{ $toastID := or $args.toastId $args.toast }}
+{{ $collapseID := or $args.collapseId $args.collapse }}
{{- if not (strings.HasSuffix $state "active") -}}
- {{- with .collapse }}{{ $collapse = . }}{{ $href = printf "#%s" . }}{{ end -}}
+ {{- with $collapseID }}{{ $href = printf "#%s" . }}{{ end -}}
+{{ else }}
+ {{- $collapseID = "" -}}
{{- end -}}
-{{- if and $tooltip $collapse -}}
+{{- if and $tooltip $collapseID -}}
{{- errorf "partial [assets/button.html] - Cannot use tooltip and collapse at the same time" -}}
{{ $error = true }}
{{- end -}}
-{{- $type := .type | default "button" -}}
-{{- $placement := .placement | default "top" -}}
-{{- $class := .class | default "" }}
-{{ with $badge }}{{ $class = printf "%s me-3" $class }}{{ end }}
-{{- $order := .order | default "last" -}}
-{{- $justify := .justify | default "center" -}}
-{{- $toast := .toast -}}
-{{- $clipboard := .clipboard -}}
-{{- $cue := .cue | default site.Params.main.externalLinks.cue -}}
-{{- $tab := .tab | default site.Params.main.externalLinks.tab -}}
+{{- $class := $args.class | default "" }}
+{{ with $args.badge }}{{ $class = printf "%s me-3" $class }}{{ end }}
+{{- $cue := $args.cue | default site.Params.main.externalLinks.cue -}}
+{{- $tab := $args.tab | default site.Params.main.externalLinks.tab -}}
{{- $isExternal := false }}
{{ if in (slice "http" "https") ((urls.Parse (absURL $href)).Scheme) }}
{{ $isExternal = ne (urls.Parse (absURL $href)).Host (urls.Parse site.BaseURL).Host -}}
{{ end }}
{{- $target := "" -}}
{{- $rel := "" -}}
-{{- $spacing := .spacing | default true -}}
{{- if $isExternal -}}
{{- if $tab -}}
@@ -73,38 +71,40 @@
{{- end -}}
{{- end -}}
-{{- $attributes := .attributes -}}
-
{{/* Main code */}}
{{ if not $error }}
-
+
{{ $title | safeHTML }}
- {{- with $icon }}{{ partial "assets/icon.html" (dict "icon" $icon "spacing" false) }}{{ end }}
+ {{- with $args.icon }}
+
+ {{ partial "assets/icon.html" (dict "icon" $args.icon "spacing" false) }}
+
+ {{ end }}
- {{- with $badge }}
+ {{- with $args.badge }}
{{ . }}
{{ with $label }}{{ . }}{{ end }}
{{- end -}}
- {{ if $spacing }} {{- end }}
+ {{ if $args.spacing }} {{- end }}
{{ end }}
\ No newline at end of file
diff --git a/layouts/_partials/assets/card-group.html b/layouts/_partials/assets/card-group.html
index 5c126ce0..a7ad19ca 100644
--- a/layouts/_partials/assets/card-group.html
+++ b/layouts/_partials/assets/card-group.html
@@ -4,38 +4,41 @@
Visit gethinode.com/license for more details.
*/}}
+{{- $error := false -}}
+
{{/* Define inline partials */}}
-{{ define "partials/inline/style.html" }}
- {{ $style := "" }}
- {{ if gt (len .styles) 0 }}
- {{ $def := index .styles (mod .index (len .styles)) }}
- {{ $style = index $def .key }}
- {{ end }}
- {{ return ($style | default .default ) }}
-{{ end }}
+{{- define "_partials/inline/style.html" -}}
+ {{- $style := "" -}}
+ {{- if gt (len .styles) 0 -}}
+ {{- $def := index .styles (mod .index (len .styles)) -}}
+ {{- $style = index $def .key -}}
+ {{- end -}}
+ {{- return ($style | default .default ) -}}
+{{- end -}}
{{/* Initialize arguments */}}
-{{ $args := partial "utilities/InitArgs.html" (dict "structure" "card-group" "child" "card" "args" .) }}
-{{ if $args.err }}
- {{ partial "utilities/LogErr.html" (dict
+{{- $args := partial "utilities/InitArgs.html" (dict "structure" "card-group" "child" "card" "args" . "group" "partial") -}}
+{{- if or $args.err $args.warnmsg -}}
+ {{- partial (cond $args.err "utilities/LogErr.html" "utilities/LogWarn.html") (dict
"partial" "assets/card-group.html"
"msg" "Invalid arguments"
- "details" $args.errmsg
+ "details" ($args.errmsg | append $args.warnmsg)
"file" page.File
)}}
-{{ end }}
+ {{- $error = $args.err -}}
+{{- end -}}
{{/* Initialize global variables */}}
-{{- $pretty := site.Params.main.internalLinks.pretty | default false }}
+{{- $pretty := site.Params.main.internalLinks.pretty | default false -}}
{{/* Initialize local variables */}}
-{{ $list := $args.list }}
+{{- $list := $args.list -}}
{{- $class := $args.class -}}
{{- $orientation := $args.orientation -}}
-{{ $cardWrapper := "" }}
+{{- $cardWrapper := "" -}}
{{- $breakpoint := partial "utilities/GetBreakpoint.html" -}}
-{{ $colsMap := dict
+{{- $colsMap := dict
"auto" ""
"1" "row-cols-1"
"2" (printf "row-cols-1 row-cols-%s-1 row-cols-%s-2" $breakpoint.prev $breakpoint.current)
@@ -43,7 +46,7 @@
"4" (printf "row-cols-1 row-cols-%s-2 row-cols-%s-4" $breakpoint.prev $breakpoint.current)
"5" (printf "row-cols-1 row-cols-%s-3 row-cols-%s-5" $breakpoint.prev $breakpoint.current)
}}
-{{ $sizesMap := dict
+{{- $sizesMap := dict
"auto" "100vw"
"1" "100vw"
"2" (printf "(min-width: %s) 50vw, 100vw" $breakpoint.currentSize)
@@ -52,53 +55,57 @@
"5" (printf "(min-width: %s) 20vw, (min-width: %s) 33.3vw, 100vw" $breakpoint.currentSize $breakpoint.prevSize)
}}
-{{ if not $args.responsive }}
- {{ $colsMap = dict "auto" "" "1" "row-cols-1" "2" "row-cols-2" "3" "row-cols-3" "4" "row-cols-4" "5" "row-cols-5" }}
- {{ $sizesMap = dict "auto" "100vw" "1" "100vw" "2" "50vw" "3" "33.3vw" "4" "25vw" "5" "20vw" }}
-{{ end }}
+{{- if not $args.responsive -}}
+ {{- $colsMap = dict "auto" "" "1" "row-cols-1" "2" "row-cols-2" "3" "row-cols-3" "4" "row-cols-4" "5" "row-cols-5" -}}
+ {{- $sizesMap = dict "auto" "100vw" "1" "100vw" "2" "50vw" "3" "33.3vw" "4" "25vw" "5" "20vw" -}}
+{{- end -}}
{{/* Apply optional pagination */}}
-{{ $isPages := in (slice "page.Pages" "resource.Resources") (printf "%T" $list) }}
-{{ $paginator := "" }}
-{{ if and $isPages $args.paginate }}
- {{ with $args.pagination }}
- {{ $paginator = $args.page.Paginate $list . }}
- {{ else }}
- {{ $paginator = $args.page.Paginate $list }}
- {{ end }}
- {{ $list = first $paginator.PagerSize (after (mul (sub $paginator.PageNumber 1) $paginator.PagerSize) $list) }}
+{{- $isPages := in (slice "page.Pages" "resource.Resources") (printf "%T" $list) -}}
+{{- $paginator := "" -}}
+{{- if and $isPages $args.paginate -}}
+ {{- with $args.pagination -}}
+ {{- $paginator = $args.page.Paginate $list . -}}
+ {{- else -}}
+ {{- $paginator = $args.page.Paginate $list -}}
+ {{- end -}}
+ {{- $list = first $paginator.PagerSize (after (mul (sub $paginator.PageNumber 1) $paginator.PagerSize) $list) -}}
- {{ page.Store.Set "paginator" $paginator }}
-{{ end }}
+ {{- page.Store.Set "paginator" $paginator -}}
+{{- end -}}
{{/* Initialize list elements */}}
-{{ $elements := slice }}
-{{ if $isPages }}
- {{ range $index, $element := $list }}
- {{ $params := dict }}
+{{- $elements := slice -}}
+{{- if $isPages -}}
+ {{- range $index, $element := $list -}}
+ {{- $params := dict -}}
{{/* regular page */}}
{{- if and $element.RelPermalink $element.File -}}
{{- $params = merge $params (dict "path" $element.File.Path) -}}
{{/* headless page */}}
{{- else -}}
{{- $thumbnail := "" -}}
- {{ if reflect.IsMap $element.Params.Thumbnail }}{{ $thumbnail = $element.Params.Thumbnail.url }}{{ else }}{{ $thumbnail = $element.Params.Thumbnail }}{{ end }}
+ {{- if reflect.IsMap $element.Params.Thumbnail }}
+ {{ $thumbnail = $element.Params.Thumbnail.url }}
+ {{ else }}
+ {{ $thumbnail = $element.Params.Thumbnail }}
+ {{ end -}}
{{- $anchor := (or (and (reflect.IsMap $element.Params.Thumbnail) $element.Params.Thumbnail.anchor) "") -}}
{{- $params = merge $params (dict
- "title" $element.Title
- "href" $element.RelPermalink
+ "title" $element.Title
+ "href" $element.RelPermalink
"description" (partial "utilities/GetDescription.html" (dict "page" $element "raw" true))
- "thumbnail" $thumbnail
- "anchor" $anchor
- "icon" $element.Params.icon
+ "thumbnail" $thumbnail
+ "anchor" $anchor
+ "icon" $element.Params.icon
) -}}
{{- end -}}
- {{- $elements = $elements | append $params }}
- {{ end }}
-{{ else if $list }}
- {{ $elements = $elements | append $list }}
-{{ end }}
+ {{- $elements = $elements | append $params -}}
+ {{- end -}}
+{{- else if $list -}}
+ {{- $elements = $elements | append $list -}}
+{{- end -}}
{{/* Limit list to max elements */}}
{{- $count := len $elements -}}
@@ -109,61 +116,62 @@
{{- end -}}
{{/* Initialize grid and layout */}}
-{{- $sizes := "100vw" }}
+{{- $sizes := "100vw" -}}
{{- $colGrid := "" -}}
-{{ if not $args.scroll }}
- {{ $colGrid = index $colsMap $args.cols }}
- {{ $sizes = index $sizesMap $args.cols }}
-{{ else }}
- {{ if in (slice "2" "3" "4" "5") $args.cols }}
- {{ $sizes = replace (printf "%.1fvw" (div 100.0 (int $args.cols))) ".0" "" }}
- {{ end }}
-{{ end }}
+{{- if not $args.scroll -}}
+ {{- $colGrid = index $colsMap (string $args.cols) -}}
+ {{- $sizes = index $sizesMap (string $args.cols) -}}
+{{- else -}}
+ {{- if in (slice "2" "3" "4" "5") $args.cols -}}
+ {{- $sizes = replace (printf "%.1fvw" (div 100.0 (int $args.cols))) ".0" "" -}}
+ {{- end -}}
+{{- end -}}
{{- if and (eq $args.cols "1") (eq $orientation "horizontal") }}{{ $orientation = "horizontal-sm" }}{{ end -}}
-{{ if not $args.spacer }}
- {{ $class = printf "%s h-100" $class }}
-{{ end }}
+{{- if not $args.spacer -}}
+ {{- $class = trim (printf "%s h-100" (or $class "")) " " -}}
+{{- end -}}
{{/* Main code */}}
-
+{{- if and (not $error) (or (gt (len $elements) 0) $args.cards) -}}
+
- {{ if $paginator }}
+ {{- if $paginator -}}
{{- if gt $paginator.TotalPages 1 -}}
-
{{ partial "assets/pagination.html" (dict "page" $args.page "format" "terse") }}
+
{{- partial "assets/pagination.html" (dict "page" $args.page "format" "terse") -}}
{{- end -}}
- {{ else }}
- {{ if and (gt $count $max) $args.hrefTitle }}
- {{ $href := $args.href }}
- {{ if and $pretty (not (hasSuffix $href "/" )) (not (strings.Contains $href "#")) }}
- {{ $href = printf "%s/" $href }}
- {{ end }}
+ {{- else -}}
+ {{- if or (and (gt $count $max) $args.hrefTitle) (and $args.hrefForce $args.hrefTitle) -}}
+ {{- $href := $args.href -}}
+ {{- if and $pretty (not (hasSuffix $href "/" )) (not (strings.Contains $href "#")) -}}
+ {{- $href = printf "%s/" $href -}}
+ {{- end -}}
{{ $args.hrefTitle }}
- {{ end }}
- {{ end }}
-
\ No newline at end of file
+ {{- end -}}
+ {{- end -}}
+
+{{- end -}}
\ No newline at end of file
diff --git a/layouts/_partials/assets/card.html b/layouts/_partials/assets/card.html
index 5b02b963..e66acf21 100644
--- a/layouts/_partials/assets/card.html
+++ b/layouts/_partials/assets/card.html
@@ -4,92 +4,10 @@
Visit gethinode.com/license for more details.
*/}}
-{{/* Validate arguments */}}
-{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "card" "args" .) }}
- {{- errorf "partial [assets/card.html] - Invalid arguments" -}}
-{{ end }}
-
-{{/* Initialize arguments and default values */}}
-{{- $alt := .alt -}}
-{{- $wrapper := .wrapper -}}
-{{- $class := .class -}}
-{{- $color := .color -}}
-{{- $description := .description -}}
-{{- $body := .body | default "full" -}}
-{{- $footer := .footer | default "none" -}}
-{{- $gutter := .gutter | default "0" -}}
-{{- $header := .header | default "full" -}}
-{{- $href := .href -}}
-{{- $icon := .icon -}}
-{{- $iconStyle := "" -}}
-{{- $iconRounded := .iconRounded | default false -}}
-{{- $align := .align | default "start" -}}
-{{- $style := .style | default "" -}}
-{{- $sizes := .sizes | default "100vw" -}}
-{{- $loading := .loading -}}
-{{- $orientation := .orientation | default "stacked" -}}
-{{- $padding := (string .padding) | default "auto" -}}
-{{- $ratio := .ratio -}}
-{{- $portrait := .portrait | default false -}}
-{{- $thumbnail := .thumbnail -}}
-{{- $anchor := .anchor | default "" -}}
-{{- $title := .title -}}
-{{- $subtle := .subtle -}}
-{{- $button := .button -}}
-{{- $buttonLabel := .buttonLabel -}}
-{{- $buttonType := .buttonType -}}
-{{- $colorStyle := "" -}}
-{{ if $color }}
- {{ if $subtle }}
- {{- $colorStyle = printf "bg-%s-subtle text-%s-emphasis" $color $color -}}
- {{ else }}
- {{- $colorStyle = printf "bg-%s text-bg-%s" $color $color -}}
- {{ end }}
-{{ end }}
-{{- $hook := .hook | default "assets/image.html" }}
-
-{{/* Override arguments */}}
-{{- $page := "" }}
-{{- if .path }}
- {{ $page = partial "utilities/GetPage.html" (dict "url" .path "page" page) }}
- {{ $validate := site.Params.main.internalLinks.validate | default true }}
- {{- if and $validate (not $page) }}
- {{ if page.File }}
- {{- warnf "partial [assets/card.html] - Cannot find target page '%s', see '%s'" .path page.File.Path -}}
- {{ else }}
- {{- warnf "partial [assets/card.html] - Cannot find target page '%s'" .path -}}
- {{ end }}
- {{- end }}
-{{- end }}
-{{- with $page -}}
- {{- if not $title }}{{ $title = .Title }}{{ end -}}
- {{- if not $href }}{{ $href = .RelPermalink }}{{ end -}}
- {{- if not $description }}{{ $description = partial "utilities/GetDescription.html" (dict "page" .) }}{{ end -}}
- {{- if and (not $thumbnail) (not $icon) }}
- {{ if reflect.IsMap .Params.Thumbnail }}{{ $thumbnail = .Params.Thumbnail.url }}{{ else }}{{ $thumbnail = .Params.Thumbnail }}{{ end }}
- {{ end -}}
- {{ if not $ratio }}
- {{- if and (reflect.IsMap .Params.Thumbnail) .Params.Thumbnail.ratio }}{{ $ratio = .Params.Thumbnail.ratio }}{{ end -}}
- {{ end }}
- {{- if not $icon }}{{ $icon = .Params.icon }}{{ end -}}
- {{- if not $anchor }}{{ $anchor = (or (and (reflect.IsMap .Params.Thumbnail) .Params.Thumbnail.anchor) "") }}{{ end -}}
-{{- end -}}
-
-{{ if (hasPrefix $orientation "horizontal") }}
- {{ if not $style }}{{ $style = "fa-fluid fa-fw" }}{{ end }}
-{{ else }}
- {{ if not $style }}{{ $style = "fa-4x" }}{{ end }}
- {{- $iconStyle = "pb-3" -}}
-{{ end }}
-
-{{- if eq $orientation "none" }}{{ $thumbnail = "" }}{{ $icon = "" }}{{ end -}}
-{{- if eq $body "title" }}{{ $description = "" }}{{ end -}}
-{{- if eq $body "none" }}{{ $title = "" }}{{ $description = "" }}{{ end -}}
-
-{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
+{{ $error := false }}
{{/* Inline partial to render the card's body */}}
-{{- define "partials/inline/card-body.html" -}}
+{{- define "_partials/inline/card-body.html" -}}
{{- $title := .title -}}
{{- $href := .href -}}
{{- $color := .color -}}
@@ -114,7 +32,7 @@
{{- end -}}
{{/* Inline partial to render the card's header or footer */}}
-{{- define "partials/inline/card-caption.html" -}}
+{{- define "_partials/inline/card-caption.html" -}}
{{- $page := .page -}}
{{- $keywords := .keywords -}}
{{- $color := .color -}}
@@ -126,7 +44,7 @@
{{- if in (slice "full" "publication") $keywords -}}
- {{ with $page.Date }}{{ partial "utilities/date.html" (dict "date" . "format" "long") }} •{{ end -}}
+ {{ with $page.Date }}{{ partial "utilities/date.html" (dict "date" . "format" "long") }} • {{ end -}}
{{ $page.ReadingTime | lang.FormatNumber 0 }} {{ i18n "minutesShort" }} {{ i18n "read" -}}
{{- end -}}
@@ -144,17 +62,90 @@
{{- end -}}
+{{/* Initialize arguments */}}
+{{ $args := partial "utilities/InitArgs.html" (dict "structure" "card" "args" . "group" "partial") }}
+{{ if or $args.err $args.warnmsg }}
+ {{ partial (cond $args.err "utilities/LogErr.html" "utilities/LogWarn.html") (dict
+ "partial" "assets/card.html"
+ "msg" "Invalid arguments"
+ "details" ($args.errmsg | append $args.warnmsg)
+ "file" page.File
+ )}}
+ {{ $error = $args.err }}
+{{ end }}
+
+{{/* Initialize arguments and default values */}}
+{{- $colorStyle := "" -}}
+{{ if $args.color }}
+ {{ if $args.subtle }}
+ {{- $colorStyle = printf "bg-%s-subtle text-%s-emphasis" $args.color $args.color -}}
+ {{ else }}
+ {{- $colorStyle = printf "bg-%s text-bg-%s" $args.color $args.color -}}
+ {{ end }}
+{{ end }}
+
+{{/* Override arguments */}}
+{{- $page := "" }}
+{{- if $args.path }}
+ {{ $page = partial "utilities/GetPage.html" (dict "url" $args.path "page" page) }}
+ {{ $validate := site.Params.main.internalLinks.validate | default true }}
+ {{- if and $validate (not $page) }}
+ {{ if page.File }}
+ {{- warnf "partial [assets/card.html] - Cannot find target page '%s', see '%s'" $args.path page.File.Path -}}
+ {{ else }}
+ {{- warnf "partial [assets/card.html] - Cannot find target page '%s'" $args.path -}}
+ {{ end }}
+ {{- end }}
+{{- end }}
+
+{{- $title := $args.title -}}
+{{- $href := $args.href -}}
+{{- $description := $args.description -}}
+{{- $thumbnail := $args.thumbnail -}}
+{{- $ratio := $args.ratio -}}
+{{- $icon := $args.icon -}}
+{{- $iconStyle := "" -}}
+{{- $anchor := $args.anchor }}
+{{- $style := $args.style }}
+
+{{- with $page -}}
+ {{- if not $args.title }}{{ $title = .Title }}{{ end -}}
+ {{- if not $args.href }}{{ $href = .RelPermalink }}{{ end -}}
+ {{- if not $args.description }}{{ $description = partial "utilities/GetDescription.html" (dict "page" .) }}{{ end -}}
+ {{- if and (not $args.thumbnail) (not $args.icon) }}
+ {{ if reflect.IsMap .Params.Thumbnail }}{{ $thumbnail = .Params.Thumbnail.url }}{{ else }}{{ $thumbnail = .Params.Thumbnail }}{{ end }}
+ {{ end -}}
+ {{ if not $args.ratio }}
+ {{- if and (reflect.IsMap .Params.Thumbnail) .Params.Thumbnail.ratio }}{{ $ratio = .Params.Thumbnail.ratio }}{{ end -}}
+ {{ end }}
+ {{- if not $args.icon }}{{ $icon = .Params.icon }}{{ end -}}
+ {{- if not $args.anchor }}{{ $anchor = (or (and (reflect.IsMap .Params.Thumbnail) .Params.Thumbnail.anchor) "") }}{{ end -}}
+{{- end -}}
+
+{{ if (hasPrefix $args.orientation "horizontal") }}
+ {{ if not $args.style }}{{ $style = "fa-fluid fa-fw" }}{{ end }}
+{{ else }}
+ {{ if not $args.style }}{{ $style = "fa-4x" }}{{ end }}
+ {{- $iconStyle = "pb-3" -}}
+{{ end }}
+
+{{- if eq $args.orientation "none" }}{{ $thumbnail = "" }}{{ $icon = "" }}{{ end -}}
+{{- if eq $args.body "title" }}{{ $description = "" }}{{ end -}}
+{{- if eq $args.body "none" }}{{ $title = "" }}{{ $description = "" }}{{ end -}}
+{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
+
+
{{/* Main code */}}
-{{ if or (ne $gutter "0") ($wrapper) }}
{{ end }}
+{{ if or (ne $args.gutter "0") ($args.wrapper) }}
{{ end }}
{{ $stack := "fa-2x" }}
-{{- if hasPrefix $orientation "horizontal" -}}
+{{- if hasPrefix $args.orientation "horizontal" -}}
{{ $col1 := "" }}
{{ $col2 := "" }}
{{ if $thumbnail }}
- {{ if eq $orientation "horizontal-sm" }}
+ {{ if eq $args.orientation "horizontal-sm" }}
{{ $stack = "fa-1x" }}
{{ $col1 = "col-4 col-md-2" }}
{{ $col2 = "col-8 col-md-10" }}
@@ -163,7 +154,7 @@
{{ $col2 = "col-8" }}
{{ end }}
{{ else if $icon }}
- {{ if eq $orientation "horizontal-sm" }}
+ {{ if eq $args.orientation "horizontal-sm" }}
{{ $stack = "fa-1x" }}
{{ $col1 = "col-2 col-sm-3 col-md-4 col-xl-2" }}
{{ $col2 = "col-10 col-sm-9 col-md-8 col-xl-10" }}
@@ -175,29 +166,29 @@
{{ end }}
{{/* Render horizontal card */}}
-