Merge pull request #250 from indrora/page-bundles

Use Page Bundles, automatically use cover file if available. Closes #249, #274
This commit is contained in:
Radek Kozieł 2021-11-01 18:49:33 +01:00 committed by GitHub
commit a634663b48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 10 deletions

View File

@ -38,9 +38,9 @@
</span> </span>
{{ end }} {{ end }}
{{ if .Params.Cover }}
<img src="{{ .Params.Cover | absURL }}" class="post-cover" alt="{{ .Title | plainify | default " " }}" /> {{ partial "cover.html" . }}
{{ end }}
<div class="post-content"> <div class="post-content">
{{ if .Params.showFullContent }} {{ if .Params.showFullContent }}

View File

@ -29,9 +29,8 @@
</span> </span>
{{ end }} {{ end }}
{{ if .Params.Cover }} {{ partial "cover.html" . }}
<img src="{{ .Params.Cover | absURL }}" class="post-cover" alt="{{ .Title | plainify | default " " }}" />
{{ end }}
<div class="post-content"> <div class="post-content">
{{ if .Params.showFullContent }} {{ if .Params.showFullContent }}

View File

@ -26,10 +26,7 @@
{{ end }} {{ end }}
</span> </span>
{{ end }} {{ end }}
{{ partial "cover.html" . }}
{{ if .Params.Cover }}
<img src="{{ .Params.Cover | absURL }}" class="post-cover" alt="{{ .Title | plainify | default " " }}" />
{{ end }}
{{ if .Params.Toc }} {{ if .Params.Toc }}
<div class="table-of-contents"> <div class="table-of-contents">

View File

@ -0,0 +1,22 @@
{{- $cover := false -}}
{{- $autoCover := default $.Site.Params.autoCover false }}
{{- if index .Params "cover" -}}
{{- if .Resources.GetMatch .Params.Cover }}
{{- $cover = (.Resources.GetMatch .Params.Cover).RelPermalink -}}
{{- else -}}
{{- $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 -}}
{{- end -}}
{{- end -}}
{{if $cover -}}
<!-- Cover image found -->
<img src="{{ $cover }}"
class="post-cover"
alt="{{ .Title | plainify | default " " }}"
title="{{ .Params.CoverCredit |plainify|default "Cover Image" }}" />
{{- end }}