From 61980c49d16a18a9ae50ac2a848640328bb3ca03 Mon Sep 17 00:00:00 2001 From: Morgan Gangwere Date: Sun, 2 May 2021 23:53:56 -0700 Subject: [PATCH 1/4] Use Page Bundles, automatically use cover file if available. --- layouts/_default/index.html | 15 ++++++++++++--- layouts/_default/list.html | 14 +++++++++++--- layouts/_default/single.html | 13 ++++++++++--- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/layouts/_default/index.html b/layouts/_default/index.html index 1a44b29..cb22592 100644 --- a/layouts/_default/index.html +++ b/layouts/_default/index.html @@ -38,9 +38,18 @@ {{ end }} - {{ if .Params.Cover }} - {{ .Title | plainify | default - {{ end }} + + {{- $cover := false -}} + {{- $autoCover := default $.Site.Params.autoCover false }} + {{- if $autoCover -}} + {{- $cover = .Resources.GetMatch "cover.*" -}} + {{- else if .Params.Cover -}} + {{- if .Resources.GetMatch .Params.Cover }} + {{ $cover = .Resources.GetMatch .Params.Cover }} + {{- end -}} + {{- end -}} + {{if $cover -}} {{ .Title | plainify | default {{- end }} +
{{ if .Params.showFullContent }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 2090966..5f97e3c 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -29,10 +29,18 @@ {{ end }} - {{ if .Params.Cover }} - {{ .Title | plainify | default - {{ end }} + {{- $cover := false -}} + {{- $autoCover := default $.Site.Params.autoCover false }} + {{- if $autoCover -}} + {{- $cover = .Resources.GetMatch "cover.*" -}} + {{- else if .Params.Cover -}} + {{- if .Resources.GetMatch .Params.Cover }} + {{ $cover = .Resources.GetMatch .Params.Cover }} + {{- end -}} + {{- end -}} + {{if $cover -}} {{ .Title | plainify | default {{- end }} +
{{ if .Params.showFullContent }} {{ .Content | markdownify }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index ad05488..1b46c1e 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -21,9 +21,16 @@ {{ end }} - {{ if .Params.Cover }} - {{ .Title | plainify | default - {{ end }} + {{- $cover := false -}} + {{- $autoCover := default $.Site.Params.autoCover false }} + {{- if $autoCover -}} + {{- $cover = .Resources.GetMatch "cover.*" -}} + {{- else if .Params.Cover -}} + {{- if .Resources.GetMatch .Params.Cover }} + {{ $cover = .Resources.GetMatch .Params.Cover }} + {{- end -}} + {{- end -}} + {{if $cover -}} {{ .Title | plainify | default {{- end }} {{ if .Params.Toc }}
From 67bb5735de3f6d6b0b4d7dac9617012ac26a41e3 Mon Sep 17 00:00:00 2001 From: Morgan Gangwere Date: Tue, 4 May 2021 19:33:35 -0700 Subject: [PATCH 2/4] Move cover to partial; need to verify that old behavior still works as intended. --- layouts/_default/index.html | 13 ++----------- layouts/_default/list.html | 11 +---------- layouts/_default/single.html | 12 +----------- layouts/partials/cover.html | 15 +++++++++++++++ 4 files changed, 19 insertions(+), 32 deletions(-) create mode 100644 layouts/partials/cover.html diff --git a/layouts/_default/index.html b/layouts/_default/index.html index cb22592..2a6f8f7 100644 --- a/layouts/_default/index.html +++ b/layouts/_default/index.html @@ -39,17 +39,8 @@ {{ end }} - {{- $cover := false -}} - {{- $autoCover := default $.Site.Params.autoCover false }} - {{- if $autoCover -}} - {{- $cover = .Resources.GetMatch "cover.*" -}} - {{- else if .Params.Cover -}} - {{- if .Resources.GetMatch .Params.Cover }} - {{ $cover = .Resources.GetMatch .Params.Cover }} - {{- end -}} - {{- end -}} - {{if $cover -}} {{ .Title | plainify | default {{- end }} - + {{ partial "cover.html" . }} +
{{ if .Params.showFullContent }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 5f97e3c..f766c16 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -29,17 +29,8 @@ {{ end }} + {{ partial "cover.html" . }} - {{- $cover := false -}} - {{- $autoCover := default $.Site.Params.autoCover false }} - {{- if $autoCover -}} - {{- $cover = .Resources.GetMatch "cover.*" -}} - {{- else if .Params.Cover -}} - {{- if .Resources.GetMatch .Params.Cover }} - {{ $cover = .Resources.GetMatch .Params.Cover }} - {{- end -}} - {{- end -}} - {{if $cover -}} {{ .Title | plainify | default {{- end }}
{{ if .Params.showFullContent }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 1b46c1e..8c8fafa 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -20,17 +20,7 @@ {{ end }} {{ end }} - - {{- $cover := false -}} - {{- $autoCover := default $.Site.Params.autoCover false }} - {{- if $autoCover -}} - {{- $cover = .Resources.GetMatch "cover.*" -}} - {{- else if .Params.Cover -}} - {{- if .Resources.GetMatch .Params.Cover }} - {{ $cover = .Resources.GetMatch .Params.Cover }} - {{- end -}} - {{- end -}} - {{if $cover -}} {{ .Title | plainify | default {{- end }} + {{ partial "cover.html" . }} {{ if .Params.Toc }}
diff --git a/layouts/partials/cover.html b/layouts/partials/cover.html new file mode 100644 index 0000000..8700c26 --- /dev/null +++ b/layouts/partials/cover.html @@ -0,0 +1,15 @@ +{{- $cover := false -}} +{{- $autoCover := default $.Site.Params.autoCover false }} +{{- if $autoCover -}} + {{- $cover = (.Resources.GetMatch "cover.*").RelPermalink -}} +{{- else if .Params.Cover -}} + {{- if .Resources.GetMatch .Params.Cover }} + {{- $cover = (.Resources.GetMatch .Params.Cover).RelPermalink -}} + {{- else -}} + {{- $cover = absURL .Params.Cover -}} + {{- end -}} +{{- end -}} +{{if $cover -}} + + {{ .Title | plainify | default +{{- end }} \ No newline at end of file From 2383eeb774acebedf82661430502bc7af24981b0 Mon Sep 17 00:00:00 2001 From: Morgan Gangwere Date: Tue, 4 May 2021 21:37:33 -0700 Subject: [PATCH 3/4] Add title from CoverCredit, if availble --- layouts/partials/cover.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/layouts/partials/cover.html b/layouts/partials/cover.html index 8700c26..deb58c1 100644 --- a/layouts/partials/cover.html +++ b/layouts/partials/cover.html @@ -11,5 +11,8 @@ {{- end -}} {{if $cover -}} - {{ .Title | plainify | default + {{ .Title | plainify | default {{- end }} \ No newline at end of file From ef0c8fef68f396cf1933132bda195104a06b0916 Mon Sep 17 00:00:00 2001 From: Morgan Gangwere Date: Fri, 7 May 2021 23:49:17 -0700 Subject: [PATCH 4/4] fix logic for getting cover information --- layouts/partials/cover.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/layouts/partials/cover.html b/layouts/partials/cover.html index deb58c1..954c49a 100644 --- a/layouts/partials/cover.html +++ b/layouts/partials/cover.html @@ -1,13 +1,17 @@ {{- $cover := false -}} {{- $autoCover := default $.Site.Params.autoCover false }} -{{- if $autoCover -}} - {{- $cover = (.Resources.GetMatch "cover.*").RelPermalink -}} -{{- else if .Params.Cover -}} +{{- 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 -}}