From e0d2c536e478b974ded30015d8a1a65f66edd937 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Sun, 6 Jul 2025 19:45:00 -0500 Subject: [PATCH] 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 }}