fix #54: root all image urls

This commit is contained in:
Jacky Zhao
2022-02-15 23:03:02 -05:00
parent cf4e921ca4
commit ce4c95b8ab
3 changed files with 9 additions and 4 deletions

View File

@ -0,0 +1,8 @@
{{$src := .Destination | safeURL }}
{{$external := strings.HasPrefix $src "http" }}
{{- if $external -}}
<img src="{{ $src }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}" {{ end }} />
{{- else -}}
{{$fixedUrl := (cond (hasPrefix $src "/") $src (print "/" $src)) | urlize}}
<img src="{{ $fixedUrl }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}" {{ end }} />
{{- end -}}