From 58f0e30d6530a54cd73e60c4e80e38882ac22f2e Mon Sep 17 00:00:00 2001 From: "kirill.chalov" Date: Thu, 5 Jun 2025 15:37:55 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20add=20default=20figure=20?= =?UTF-8?q?shortcode=20as=20partial?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hugo v0.146 removed access to embedded templates like "_internal/shortcodes/figure.html". This commit adds the template as figure-default.html. This fixes build errors reported and partially solved in issues #2052 and #2093 when using the figure shortcode with the "default=true" option. --- .../shortcodes/figure-default.html | 43 +++++++++++++++++++ layouts/shortcodes/figure.html | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 layouts/partials/hugo-embedded/shortcodes/figure-default.html diff --git a/layouts/partials/hugo-embedded/shortcodes/figure-default.html b/layouts/partials/hugo-embedded/shortcodes/figure-default.html new file mode 100644 index 00000000..e74d30be --- /dev/null +++ b/layouts/partials/hugo-embedded/shortcodes/figure-default.html @@ -0,0 +1,43 @@ +{{/* + Copied from Hugo v0.146 + Source: https://github.com/gohugoio/hugo/blob/83cfdd78ca6469e6d7265323d9fad1448880e559/tpl/tplimpl/embedded/templates/_shortcodes/figure.html +*/}} + + + {{- if .Get "link" -}} + + {{- end -}} + + {{- $u := urls.Parse (.Get "src") -}} + {{- $src := $u.String -}} + {{- if not $u.IsAbs -}} + {{- with or (.Page.Resources.Get $u.Path) (resources.Get $u.Path) -}} + {{- $src = .RelPermalink -}} + {{- end -}} + {{- end -}} + + {{ with .Get + {{- if .Get "link" }}{{ end -}} + {{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}} +
+ {{ with (.Get "title") -}} +

{{ . }}

+ {{- end -}} + {{- if or (.Get "caption") (.Get "attr") -}}

+ {{- .Get "caption" | markdownify -}} + {{- with .Get "attrlink" }} + + {{- end -}} + {{- .Get "attr" | markdownify -}} + {{- if .Get "attrlink" }}{{ end }}

+ {{- end }} +
+ {{- end }} + diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html index f4c03935..0b429187 100644 --- a/layouts/shortcodes/figure.html +++ b/layouts/shortcodes/figure.html @@ -1,6 +1,6 @@ {{ $disableImageOptimization := .Site.Params.disableImageOptimization | default false }} {{ if .Get "default" }} - {{ partial "shortcodes/figure.html" . }} + {{ partial "hugo-embedded/shortcodes/figure-default.html" . }} {{ else }} {{- $url := urls.Parse (.Get "src") }} {{- $altText := .Get "alt" }}