Allow single page and list layouts to make use of a full URL for the cover

This commit is contained in:
Eelco Wesemann 2019-02-05 16:27:59 +01:00
parent 58fbfec07b
commit 7e813c3565
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 }}