diff --git a/layouts/_default/index.html b/layouts/_default/index.html index 59b8e5d..50065c6 100644 --- a/layouts/_default/index.html +++ b/layouts/_default/index.html @@ -38,9 +38,9 @@ {{ end }} - {{ if .Params.Cover }} - {{ .Title | plainify | default - {{ end }} + + {{ partial "cover.html" . }} +
{{ if .Params.showFullContent }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 4d2083b..8b8f7b2 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -29,10 +29,9 @@ {{ end }} - {{ if .Params.Cover }} - {{ .Title | plainify | default - {{ end }} + {{ partial "cover.html" . }} +
{{ if .Params.showFullContent }} {{ .Content }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 8c15946..09c5754 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -26,10 +26,7 @@ {{ end }} {{ end }} - - {{ if .Params.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..954c49a --- /dev/null +++ b/layouts/partials/cover.html @@ -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 -}} + + {{ .Title | plainify | default +{{- end }} \ No newline at end of file