From d02b9177d98b77faca6e72e6a4c85a043c421033 Mon Sep 17 00:00:00 2001 From: pann Date: Sat, 19 Sep 2020 23:49:34 +0800 Subject: [PATCH] fix markdown image issue --- layouts/_default/_markup/render-image.html | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index a79cddf03..9e09b98a5 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,10 +1,16 @@ -{{- if .Title -}} +{{ $figcap := or .Title .Text }} +{{ $caption := or .Text " " }} +{{- if eq $figcap $caption -}} + {{ $caption = " " }} +{{- end -}} + +{{- if $figcap -}}
- {{- dict "Src" .Destination "Title" .Text "Caption" .Title "Linked" true "Resources" .Page.Resources | partial "plugin/image.html" -}} + {{- dict "Src" .Destination "Title" $figcap "Caption" $caption "Linked" true "Resources" .Page.Resources | partial "plugin/image.html" -}}
- {{- .Title | safeHTML -}} + {{- $figcap | safeHTML -}}
{{- else -}} - {{- dict "Src" .Destination "Title" .Text "Resources" .Page.Resources | partial "plugin/image.html" -}} + {{- dict "Src" .Destination "Title" (path.Base .Destination) "Resources" .Page.Resources | partial "plugin/image.html" -}} {{- end -}}