Allow full URL to be used for cover

This commit is contained in:
Eelco Wesemann 2019-02-06 10:49:04 +01:00
parent e6f8847460
commit 323caa5d3c
2 changed files with 12 additions and 2 deletions

View File

@ -23,8 +23,13 @@
{{ end }} {{ end }}
{{ with .Params.Cover }} {{ with .Params.Cover }}
{{ $imgurl := urls.Parse . }}
{{ if $imgurl.Scheme }}
<img src="{{ printf "%s" . | safeURL }}" class="post-cover" />
{{ else }}
<img src="{{ printf "img/%s" . | absURL }}" class="post-cover" /> <img src="{{ printf "img/%s" . | absURL }}" class="post-cover" />
{{ end }} {{ end }}
{{ end }}
<div class="post-content"> <div class="post-content">
{{ with .Description }} {{ with .Description }}

View File

@ -17,8 +17,13 @@
{{ end }} {{ end }}
{{ with .Params.Cover }} {{ with .Params.Cover }}
{{ $imgurl := urls.Parse . }}
{{ if $imgurl.Scheme }}
<img src="{{ printf "%s" . | safeURL }}" class="post-cover" />
{{ else }}
<img src="{{ printf "img/%s" . | absURL }}" class="post-cover" /> <img src="{{ printf "img/%s" . | absURL }}" class="post-cover" />
{{ end }} {{ end }}
{{ end }}
<div class="post-content"> <div class="post-content">
{{ .Content }} {{ .Content }}