mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2024-12-24 14:49:22 -05:00
post-cover: add support for relative path for cover image
* checks whether path mentioned in `cover` page-variable exists OR is an external url, else sets the relative path for image w.r.t the post the cover is of.
This commit is contained in:
parent
f4df89dbf6
commit
d8199140e5
@ -33,7 +33,11 @@
|
||||
<article class="{{ $class }}">
|
||||
{{- if .Params.cover }}
|
||||
<figure class="entry-cover">
|
||||
<img src="{{ .Params.cover | absURL }}" alt="cover image for {{ .Title }}">
|
||||
{{ if (or (fileExists (path.Join "static" .Params.cover)) (hasPrefix .Params.cover "http://") (hasPrefix .Params.cover "https://")) }}
|
||||
<img src="{{ .Params.cover | absURL }}" alt="cover image for {{ .Title | plainify }}">
|
||||
{{else}}
|
||||
<img src="{{ .Permalink -}} {{- .Params.cover }}" alt="cover image for {{ .Title | plainify }}">
|
||||
{{end}}
|
||||
</figure>
|
||||
{{- end }}
|
||||
<header class="entry-header">
|
||||
|
@ -28,7 +28,11 @@
|
||||
</header>
|
||||
{{- if .Params.cover }}
|
||||
<figure class="entry-cover">
|
||||
{{ if (or (fileExists (path.Join "static" .Params.cover)) (hasPrefix .Params.cover "http://") (hasPrefix .Params.cover "https://")) }}
|
||||
<img src="{{ .Params.cover | absURL }}" alt="cover image for {{ .Title | plainify }}">
|
||||
{{else}}
|
||||
<img src="{{ .Permalink -}} {{- .Params.cover }}" alt="cover image for {{ .Title | plainify }}">
|
||||
{{end}}
|
||||
</figure>
|
||||
{{- end }}
|
||||
{{- if .Params.ShowToc }}
|
||||
|
Loading…
Reference in New Issue
Block a user