{{- $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 $ctx.Params "cover" -}} {{- if .Resources.GetMatch $ctx.Params.Cover }} {{- $cover = (.Resources.GetMatch $ctx.Params.Cover).RelPermalink -}} {{- else -}} {{- $cover = absURL $ctx.Params.Cover -}} {{- end -}} {{- else if $.Site.Params.AutoCover -}} {{- if (not $ctx.Params.Cover) -}} {{- if .Resources.GetMatch "cover.*" -}} {{- $cover = (.Resources.GetMatch "cover.*").RelPermalink -}} {{- end -}} {{- end -}} {{- end -}} {{- if $cover -}} {{ if and $ctx.Params.coverCaption $isCoverCaptionEnabled }}
{{ .Title | plainify | default
{{ $ctx.Params.coverCaption | safeHTML }}
{{ else }} {{ .Title | plainify | default {{ end }} {{- end }}