From 67bb5735de3f6d6b0b4d7dac9617012ac26a41e3 Mon Sep 17 00:00:00 2001 From: Morgan Gangwere Date: Tue, 4 May 2021 19:33:35 -0700 Subject: [PATCH] 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