From e9aae285a698b86089a13e328caaa32a771103b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20P=C3=A4pper?= Date: Tue, 19 Mar 2019 17:47:05 +0100 Subject: [PATCH] Improved code by using UseRelativeCover flag to post rather than having cover and relcover to avoid code duplication --- README.md | 2 +- layouts/_default/list.html | 13 ++++++------- layouts/_default/single.html | 13 ++++++------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 4210936..fb738f0 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ Adding a cover image to your post is simple and there are two options when you e * Use `cover: "/path/to/absolute/img.jpg"` to link an absolute image * Resulting in `https://www.yourpage.com/path/to/absolute/img.jpg` -* Use `relcover: "img.jpg"` to link the image relative to the blog post folder +* Use `cover: "img.jpg"` and `useRelativeCover: true` to link the image relative to the blog post folder * Resulting in `https://www.yourpage.com/posts/blog-entry-xy/img.jpg` ## Add-ons diff --git a/layouts/_default/list.html b/layouts/_default/list.html index cc21579..c8dbbe5 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -26,13 +26,12 @@ {{ end }} - {{ $permalink := .Permalink }} - {{ with .Params.RelCover }} - - {{ end }} - - {{ with .Params.Cover }} - + {{ if .Params.Cover }} + {{ if .Params.UseRelativeCover }} + + {{ else }} + + {{ end }} {{ end }}
diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 0050a8c..12bc91d 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -20,14 +20,13 @@ {{ end }} {{ end }} - - {{ $permalink := .Permalink }} - {{ with .Params.RelCover }} - - {{ end }} - {{ with .Params.Cover }} - + {{ if .Params.Cover }} + {{ if .Params.UseRelativeCover }} + + {{ else }} + + {{ end }} {{ end }}