post-cover: relative covers need to be explicitely set

* change in d819914 and #13
* previous impl breks sites not using `/static` dir as their static location
* hugo supports multiple static directories and previous impl checks only for one
* ref : https://gohugo.io/content-management/static-files/

usage change in post-vars =>

cover:
  image: '<relative url>'
  relative: true
This commit is contained in:
Aditya Telange 2020-10-10 19:52:08 +05:30
parent 3ca79f59fe
commit a8abbd3545
No known key found for this signature in database
GPG Key ID: 82E844EF3DA99E77
2 changed files with 2 additions and 2 deletions

View File

@ -33,7 +33,7 @@
<article class="{{ $class }}"> <article class="{{ $class }}">
{{- if .Params.cover.image }} {{- if .Params.cover.image }}
<figure class="entry-cover"> <figure class="entry-cover">
{{- if (or (fileExists (path.Join "static" .Params.cover.image)) (hasPrefix .Params.cover.image "http://") (hasPrefix .Params.cover.image "https://")) }} {{- if (ne .Params.cover.relative true) }}
<img src="{{ .Params.cover.image | absURL }}" alt="{{ .Params.cover.alt | plainify }}"> <img src="{{ .Params.cover.image | absURL }}" alt="{{ .Params.cover.alt | plainify }}">
{{- else}} {{- else}}
<img src="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" alt="{{ .Params.cover.alt | plainify }}"> <img src="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" alt="{{ .Params.cover.alt | plainify }}">

View File

@ -28,7 +28,7 @@
</header> </header>
{{- if .Params.cover.image }} {{- if .Params.cover.image }}
<figure class="entry-cover"> <figure class="entry-cover">
{{- if (or (fileExists (path.Join "static" .Params.cover.image)) (hasPrefix .Params.cover.image "http://") (hasPrefix .Params.cover.image "https://")) }} {{- if (ne .Params.cover.relative true) }}
<img src="{{ .Params.cover.image | absURL }}" alt="{{ .Params.cover.alt | plainify }}"> <img src="{{ .Params.cover.image | absURL }}" alt="{{ .Params.cover.alt | plainify }}">
{{- else}} {{- else}}
<img src="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" alt="{{ .Params.cover.alt | plainify }}"> <img src="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" alt="{{ .Params.cover.alt | plainify }}">