{{ .Content }} diff --git a/layouts/summary.html b/layouts/summary.html index a47a616..b690259 100644 --- a/layouts/summary.html +++ b/layouts/summary.html @@ -6,11 +6,7 @@ {{ partial "page-metadata/post-short.html" . }} -{{ with .Resources.GetMatch "feature" }} -
- {{ partial "figure.html" (dict "src" .) }} -
-{{ end }} +{{ partial "feature-figure.html" . }}
{{ partial "description-or-summary.html" . }} From e0d2c536e478b974ded30015d8a1a65f66edd937 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Sun, 6 Jul 2025 19:45:00 -0500 Subject: [PATCH 2/8] WIP --- layouts/_markup/render-image.html | 16 ++++++++++------ layouts/_shortcodes/figure.html | 19 ++++++++++++++----- layouts/_shortcodes/resource.html | 9 +++++++++ 3 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 layouts/_shortcodes/resource.html diff --git a/layouts/_markup/render-image.html b/layouts/_markup/render-image.html index 42e9213..6f83f10 100644 --- a/layouts/_markup/render-image.html +++ b/layouts/_markup/render-image.html @@ -1,8 +1,12 @@ +{{/* TODO: should we use .PageInner */}} +{{ partial "embed-resource.html" (.Page.Resources.Get .Destination) }} {{ with .Title }} -
- {{ partial "embed-resource.html" ($.Page.Resources.Get $.Destination) }} -
{{ . }}
-
-{{ else }} - {{ partial "embed-resource.html" (.Page.Resources.Get .Destination) }} + {{ errorf "%q" . }} +{{ end }} +{{ with .Attributes }} + {{/* FIXME: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_markup/render-image.html */}} + {{ errorf "%q" . }} +{{ end }} +{{ with .Text }} + {{ errorf "%q" . }} {{ end }} diff --git a/layouts/_shortcodes/figure.html b/layouts/_shortcodes/figure.html index 96c1b38..8bac195 100644 --- a/layouts/_shortcodes/figure.html +++ b/layouts/_shortcodes/figure.html @@ -1,8 +1,17 @@ -

-

+
+ {{ with .Get "src" }} + {{ with $.Page.Resources.Get . }} + {{ partial "embed-resource.html" . }} + {{ with .Title }} +
{{ . | markdownify }}
+ {{ end }} + {{ else }} + {{ errorf "resource %q not found" . }} + {{ end }} + {{ else }} {{ .Inner }} {{ with .Get "caption" }} -
{{ . }}
+
{{ . | markdownify }}
{{ end }} -
-

+ {{ end }} +
diff --git a/layouts/_shortcodes/resource.html b/layouts/_shortcodes/resource.html new file mode 100644 index 0000000..c223dd7 --- /dev/null +++ b/layouts/_shortcodes/resource.html @@ -0,0 +1,9 @@ +{{ with .Get 0 }} + {{ with $.Page.Resources.Get . }} + {{ partial "embed-resource.html" . }} + {{ else }} + {{ errorf "resource %q not found" . }} + {{ end }} +{{ else }} + {{ errorf "resource name not provided as first parameter" }} +{{ end }} From 2fa53d1f2c96e22e844da5871f5a26454147d50c Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Sun, 27 Jul 2025 00:44:45 -0500 Subject: [PATCH 3/8] Remove render-image override We can just use the resource shortcode in content files --- hugo.yaml | 2 -- layouts/_markup/render-image.html | 12 ------------ 2 files changed, 14 deletions(-) delete mode 100644 layouts/_markup/render-image.html diff --git a/hugo.yaml b/hugo.yaml index 3d8a3a2..54ddc67 100644 --- a/hugo.yaml +++ b/hugo.yaml @@ -4,8 +4,6 @@ markup: lineNos: true goldmark: parser: - # don't put

around ![]() image in markdown (used to embed any resource now) - wrapStandAloneImageWithinParagraph: false attribute: block: true # this is enabled by default already diff --git a/layouts/_markup/render-image.html b/layouts/_markup/render-image.html deleted file mode 100644 index 6f83f10..0000000 --- a/layouts/_markup/render-image.html +++ /dev/null @@ -1,12 +0,0 @@ -{{/* TODO: should we use .PageInner */}} -{{ partial "embed-resource.html" (.Page.Resources.Get .Destination) }} -{{ with .Title }} - {{ errorf "%q" . }} -{{ end }} -{{ with .Attributes }} - {{/* FIXME: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_markup/render-image.html */}} - {{ errorf "%q" . }} -{{ end }} -{{ with .Text }} - {{ errorf "%q" . }} -{{ end }} From d6cb2c12c85243e9eda5931d08c7038760c8520b Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Sun, 27 Jul 2025 01:43:59 -0500 Subject: [PATCH 4/8] Fix markdown rendering on caption of featured image --- layouts/_partials/feature-figure.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/_partials/feature-figure.html b/layouts/_partials/feature-figure.html index 383c3b7..01df020 100644 --- a/layouts/_partials/feature-figure.html +++ b/layouts/_partials/feature-figure.html @@ -3,7 +3,7 @@

{{ partial "embed-resource.html" . }} {{ with .Title }} -
{{ . }}
+
{{ . | markdownify }}
{{ end }}
From 8f79d2af3a370b560cbf2c0f48c6c972e2028b6c Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Sun, 27 Jul 2025 01:44:08 -0500 Subject: [PATCH 5/8] Allow using positional parameter for figure caption --- layouts/_shortcodes/figure.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/_shortcodes/figure.html b/layouts/_shortcodes/figure.html index 8bac195..e34f52a 100644 --- a/layouts/_shortcodes/figure.html +++ b/layouts/_shortcodes/figure.html @@ -10,7 +10,7 @@ {{ end }} {{ else }} {{ .Inner }} - {{ with .Get "caption" }} + {{ with or (.Get "caption") (.Get 0) }}
{{ . | markdownify }}
{{ end }} {{ end }} From f371afe5294f1edfc74df848fd4ba385a5b2842a Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Sun, 27 Jul 2025 02:34:44 -0500 Subject: [PATCH 6/8] Support using src with custom caption parameter in figure shortcode --- layouts/_shortcodes/figure.html | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/layouts/_shortcodes/figure.html b/layouts/_shortcodes/figure.html index e34f52a..6fd54bd 100644 --- a/layouts/_shortcodes/figure.html +++ b/layouts/_shortcodes/figure.html @@ -2,16 +2,14 @@ {{ with .Get "src" }} {{ with $.Page.Resources.Get . }} {{ partial "embed-resource.html" . }} - {{ with .Title }} -
{{ . | markdownify }}
- {{ end }} {{ else }} {{ errorf "resource %q not found" . }} {{ end }} {{ else }} {{ .Inner }} - {{ with or (.Get "caption") (.Get 0) }} -
{{ . | markdownify }}
- {{ end }} + {{ end }} + + {{ with or (.Get "caption") (.Get 0) .Title }} +
{{ . | markdownify }}
{{ end }}