Skip to content

Commit

Permalink
fix: set the caption as title if present (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Mar 15, 2024
1 parent 767df64 commit 59b9b9f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion layouts/partials/images/figure.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<figure class="{{ .figureClass }} {{ .wrapperClass }}">
{{ partial "images/picture" (merge .ctx (dict "className" (printf "%s %s" .figureImgClass .className))) }}
<figcaption class="{{ .figureCaptionClass }}">{{ .caption }}</figcaption>
<figcaption class="{{ .figureCaptionClass }}">{{ .ctx.caption }}</figcaption>
</figure>
2 changes: 1 addition & 1 deletion layouts/partials/images/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
"className" $className
"src" $src
"alt" $alt
"caption" $caption
"lazyLoading" $lazyLoading
"naturalHeight" $naturalHeight
"naturalWidth" $naturalWidth
Expand All @@ -222,7 +223,6 @@
"figureImgClass" $figureImgClass
"className" $className
"figureCaptionClass" $figureCaptionClass
"caption" $caption
"ctx" $ctx
) }}
{{- else }}
Expand Down
3 changes: 3 additions & 0 deletions layouts/partials/images/picture.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit 59b9b9f

Please sign in to comment.