diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 00b8b86..8681d5f 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -29,7 +29,7 @@ {{ end }} {{ end }} - {{ partial "cover.html" . }} + {{ partial "cover.html" (dict "ctx" . "isCoverCaptionEnabled" true) }} {{ if (.Params.Toc | default .Site.Params.Toc) }}
diff --git a/layouts/partials/cover.html b/layouts/partials/cover.html index 58800cf..df1804a 100644 --- a/layouts/partials/cover.html +++ b/layouts/partials/cover.html @@ -1,37 +1,54 @@ + + +{{- $ctx := "" -}} +{{- $isCoverCaptionEnabled := default nil -}} +{{- if (reflect.IsMap . ) -}} + {{- /* Assign Custom Context */ -}} + {{- $ctx = .ctx -}} + {{- /* Assign value of .isCoverCaptionEnabled */ -}} + {{- $isCoverCaptionEnabled = cond (not .isCoverCaptionEnabled) nil .isCoverCaptionEnabled -}} +{{- else -}} + {{- /* Passing dot context, default behaviour */ -}} + {{- $ctx = . -}} + {{- /* Default isCoverCaptionEnabled for Dot Context */ -}} + {{- $isCoverCaptionEnabled = false -}} +{{- end -}} + + {{- $cover := false -}} {{- $autoCover := default $.Site.Params.autoCover false }} -{{- if index .Params "cover" -}} - {{- if .Resources.GetMatch .Params.Cover }} - {{- $cover = (.Resources.GetMatch .Params.Cover).RelPermalink -}} +{{- if index $ctx.Params "cover" -}} + {{- if .Resources.GetMatch $ctx.Params.Cover }} + {{- $cover = (.Resources.GetMatch $ctx.Params.Cover).RelPermalink -}} {{- else -}} - {{- $cover = absURL .Params.Cover -}} + {{- $cover = absURL $ctx.Params.Cover -}} {{- end -}} {{- else if $.Site.Params.AutoCover -}} - {{- if (not .Params.Cover) -}} + {{- if (not $ctx.Params.Cover) -}} {{- if .Resources.GetMatch "cover.*" -}} {{- $cover = (.Resources.GetMatch "cover.*").RelPermalink -}} {{- end -}} {{- end -}} {{- end -}} -{{if $cover -}} - {{ if .Params.coverCaption }} +{{- if $cover -}} + {{ if and $ctx.Params.coverCaption $isCoverCaptionEnabled }}
{{ .Title | plainify | default + title="{{ $ctx.Params.CoverCredit |plainify|default "Cover Image" }}" /> -
{{ .Params.coverCaption | safeHTML }}
+
{{ $ctx.Params.coverCaption | safeHTML }}
{{ else }} {{ .Title | plainify | default + title="{{ $ctx.Params.CoverCredit |plainify|default "Cover Image" }}" /> {{ end }} {{- end }} diff --git a/layouts/partials/single_basic.html b/layouts/partials/single_basic.html index 5e92cea..08ba0ae 100644 --- a/layouts/partials/single_basic.html +++ b/layouts/partials/single_basic.html @@ -67,7 +67,7 @@ HERE INSERT ANY CUSTOM