From e77948f3cd81e27c62787f2552d4be57f8a6c8d0 Mon Sep 17 00:00:00 2001 From: panr Date: Mon, 1 Nov 2021 18:53:02 +0100 Subject: [PATCH] fix autocover partial --- README.md | 5 +++++ layouts/partials/cover.html | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1a975ec..af631ca 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,11 @@ paginate = 5 # it's set to `true` by default # oneHeadingSize = false + # if your resource directory contains an image called `cover.(jpg|png|webp)`, + # then the file will be used as a cover automatically. + # With this option you don't have to put the `cover` param in a front-matter. + # autoCover = true + [params.twitter] # set Twitter handles for Twitter cards # see https://developer.twitter.com/en/docs/tweets/optimize-with-cards/guides/getting-started#card-and-content-attribution diff --git a/layouts/partials/cover.html b/layouts/partials/cover.html index 954c49a..ea562ea 100644 --- a/layouts/partials/cover.html +++ b/layouts/partials/cover.html @@ -1,5 +1,6 @@ {{- $cover := false -}} {{- $autoCover := default $.Site.Params.autoCover false }} + {{- if index .Params "cover" -}} {{- if .Resources.GetMatch .Params.Cover }} {{- $cover = (.Resources.GetMatch .Params.Cover).RelPermalink -}} @@ -7,16 +8,17 @@ {{- $cover = absURL .Params.Cover -}} {{- end -}} {{- else if $.Site.Params.AutoCover -}} - {{- if and ( index .Params "cover" ) (not .Params.Cover) -}} - {{- if .Resources.GetMatch "cover.*" -}} - {{- $cover = (.Resources.GetMatch "cover.*").RelPermalink -}} - {{- end -}} + {{- if (not .Params.Cover) -}} + {{- if .Resources.GetMatch "cover.*" -}} + {{- $cover = (.Resources.GetMatch "cover.*").RelPermalink -}} + {{- end -}} {{- end -}} {{- end -}} + {{if $cover -}} {{ .Title | plainify | default -{{- end }} \ No newline at end of file +{{- end }}