🐛 Fix support for Hugo default figure shortcode

Fixes: #1074
This commit is contained in:
James Panther
2025-06-23 08:56:12 +10:00
parent b58e81d746
commit 65ceb3d1b1
2 changed files with 39 additions and 1 deletions
+1
View File
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Fixed ### Fixed
- `figure` shortcode would load recursively when using the `default` paramater ([#1074](https://github.com/jpanther/congo/issues/1074))
- Some partials not loading due to incorrect file paths ([#1075](https://github.com/jpanther/congo/pull/1075)) - Some partials not loading due to incorrect file paths ([#1075](https://github.com/jpanther/congo/pull/1075))
## [2.12.0] - 2025-06-22 ## [2.12.0] - 2025-06-22
+38 -1
View File
@@ -1,5 +1,42 @@
{{ if .Get "default" }} {{ if .Get "default" }}
{{ template "_shortcodes/figure.html" . }} <figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
{{- if .Get "link" -}}
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
{{- 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 -}}
<img src="{{ $src }}"
{{- if or (.Get "alt") (.Get "caption") }}
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
{{- end -}}
{{- with .Get "width" }} width="{{ . }}"{{ end -}}
{{- with .Get "height" }} height="{{ . }}"{{ end -}}
{{- with .Get "loading" }} loading="{{ . }}"{{ end -}}
><!-- Closing img tag -->
{{- if .Get "link" }}</a>{{ end -}}
{{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}}
<figcaption>
{{ with (.Get "title") -}}
<h4>{{ . }}</h4>
{{- end -}}
{{- if or (.Get "caption") (.Get "attr") -}}<p>
{{- .Get "caption" | markdownify -}}
{{- with .Get "attrlink" }}
<a href="{{ . }}">
{{- end -}}
{{- .Get "attr" | markdownify -}}
{{- if .Get "attrlink" }}</a>{{ end }}</p>
{{- end }}
</figcaption>
{{- end }}
</figure>
{{ else }} {{ else }}
{{ $url := urls.Parse (.Get "src") }} {{ $url := urls.Parse (.Get "src") }}
{{ $altText := .Get "alt" }} {{ $altText := .Get "alt" }}