mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2024-11-22 02:21:37 +01: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 }}">
|
<article class="{{ $class }}">
|
||||||
{{- if .Params.cover }}
|
{{- if .Params.cover }}
|
||||||
<figure class="entry-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>
|
</figure>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
<header class="entry-header">
|
<header class="entry-header">
|
||||||
|
@ -28,7 +28,11 @@
|
|||||||
</header>
|
</header>
|
||||||
{{- if .Params.cover }}
|
{{- if .Params.cover }}
|
||||||
<figure class="entry-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 }}">
|
<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>
|
</figure>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if .Params.ShowToc }}
|
{{- if .Params.ShowToc }}
|
||||||
|
Loading…
Reference in New Issue
Block a user