From d8199140e5940f02960196d1220c9a0ce8a23de1 Mon Sep 17 00:00:00 2001 From: Aditya Telange <21258296+adityatelange@users.noreply.github.com> Date: Sun, 4 Oct 2020 09:23:27 +0530 Subject: [PATCH] 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. --- layouts/_default/list.html | 6 +++++- layouts/_default/single.html | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 2d728e07..ef3ef296 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -33,7 +33,11 @@
{{- if .Params.cover }}
- cover image for {{ .Title }} + {{ if (or (fileExists (path.Join "static" .Params.cover)) (hasPrefix .Params.cover "http://") (hasPrefix .Params.cover "https://")) }} + cover image for {{ .Title | plainify }} + {{else}} + cover image for {{ .Title | plainify }} + {{end}}
{{- end }}
diff --git a/layouts/_default/single.html b/layouts/_default/single.html index fc95dc63..7cdea8c9 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -28,7 +28,11 @@
{{- if .Params.cover }}
+ {{ if (or (fileExists (path.Join "static" .Params.cover)) (hasPrefix .Params.cover "http://") (hasPrefix .Params.cover "https://")) }} cover image for {{ .Title | plainify }} + {{else}} + cover image for {{ .Title | plainify }} + {{end}}
{{- end }} {{- if .Params.ShowToc }}