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