use RelPermalink for markdown images

This commit is contained in:
Reorx 2022-05-20 18:19:35 +08:00
parent 3f1e99e8b4
commit 228cf0d83f
1 changed files with 9 additions and 1 deletions

View File

@ -1 +1,9 @@
<img loading="lazy" src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}" {{ end }} />
{{- $img := .Page.Resources.GetMatch .Destination -}}
{{- if and (not $img) .Page.File -}}
{{ $path := path.Join .Page.File.Dir .Destination }}
{{- $img = resources.Get $path -}}
{{- end -}}
{{- with $img -}}
<img loading="lazy" src="{{ $img.RelPermalink }}" alt="{{ $.Text }}" {{ with $.Title}} title="{{ . }}" {{ end }} />
{{- end -}}