From a8abbd35452e6a98777e8a618114b0147368d98e Mon Sep 17 00:00:00 2001
From: Aditya Telange <21258296+adityatelange@users.noreply.github.com>
Date: Sat, 10 Oct 2020 19:52:08 +0530
Subject: [PATCH] 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
---
 layouts/_default/list.html   | 2 +-
 layouts/_default/single.html | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/layouts/_default/list.html b/layouts/_default/list.html
index 474d7f7..0b2f0f3 100644
--- a/layouts/_default/list.html
+++ b/layouts/_default/list.html
@@ -33,7 +33,7 @@
 <article class="{{ $class }}">
   {{- if .Params.cover.image }}
   <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 }}">
     {{- else}}
     <img src="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" alt="{{ .Params.cover.alt | plainify }}">
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index a4c847f..ef5d6f3 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -28,7 +28,7 @@
   </header>
   {{- if .Params.cover.image }}
   <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 }}">
     {{- else}}
     <img src="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" alt="{{ .Params.cover.alt | plainify }}">