fix autocover partial

This commit is contained in:
panr 2021-11-01 18:53:02 +01:00
parent a634663b48
commit e77948f3cd
2 changed files with 12 additions and 5 deletions

View File

@ -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

View File

@ -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,12 +8,13 @@
{{- $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 -}}
<!-- Cover image found -->
<img src="{{ $cover }}"