From 59b9b9f0baf528b8fcd96ce920587c32cbd14717 Mon Sep 17 00:00:00 2001 From: Razon Yang Date: Fri, 15 Mar 2024 10:14:26 +0800 Subject: [PATCH] fix: set the caption as title if present (#50) --- layouts/partials/images/figure.html | 2 +- layouts/partials/images/image.html | 2 +- layouts/partials/images/picture.html | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/layouts/partials/images/figure.html b/layouts/partials/images/figure.html index 1d853a7..5ebc076 100644 --- a/layouts/partials/images/figure.html +++ b/layouts/partials/images/figure.html @@ -1,4 +1,4 @@
{{ partial "images/picture" (merge .ctx (dict "className" (printf "%s %s" .figureImgClass .className))) }} -
{{ .caption }}
+
{{ .ctx.caption }}
diff --git a/layouts/partials/images/image.html b/layouts/partials/images/image.html index 6f78fb0..5fa8b33 100644 --- a/layouts/partials/images/image.html +++ b/layouts/partials/images/image.html @@ -203,6 +203,7 @@ "className" $className "src" $src "alt" $alt + "caption" $caption "lazyLoading" $lazyLoading "naturalHeight" $naturalHeight "naturalWidth" $naturalWidth @@ -222,7 +223,6 @@ "figureImgClass" $figureImgClass "className" $className "figureCaptionClass" $figureCaptionClass - "caption" $caption "ctx" $ctx ) }} {{- else }} diff --git a/layouts/partials/images/picture.html b/layouts/partials/images/picture.html index 22d5586..db32df4 100644 --- a/layouts/partials/images/picture.html +++ b/layouts/partials/images/picture.html @@ -7,6 +7,9 @@ (printf `src="%s"` .src) (printf `alt="%s"` .alt) }} + {{- with .caption }} + {{- $attrs = $attrs | append (printf `title="%s"` .) }} + {{- end }} {{- if .lazyLoading }} {{- $attrs = $attrs | append `loading="lazy"` }} {{- end }}