hugo-theme-re-terminal/layouts/partials/cover.html

55 lines
1.7 KiB
HTML
Raw Normal View History

2024-08-23 11:35:27 +00:00
{{- $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 -}}
2022-06-21 13:50:51 +00:00
{{- $cover := false -}}
{{- $autoCover := default $.Site.Params.autoCover false }}
2024-08-23 11:35:27 +00:00
{{- if index $ctx.Params "cover" -}}
{{- if .Resources.GetMatch $ctx.Params.Cover }}
{{- $cover = (.Resources.GetMatch $ctx.Params.Cover).RelPermalink -}}
2022-06-21 13:50:51 +00:00
{{- else -}}
2024-08-23 11:35:27 +00:00
{{- $cover = absURL $ctx.Params.Cover -}}
2022-06-21 13:50:51 +00:00
{{- end -}}
{{- else if $.Site.Params.AutoCover -}}
2024-08-23 11:35:27 +00:00
{{- if (not $ctx.Params.Cover) -}}
2022-06-21 13:50:51 +00:00
{{- if .Resources.GetMatch "cover.*" -}}
{{- $cover = (.Resources.GetMatch "cover.*").RelPermalink -}}
{{- end -}}
{{- end -}}
{{- end -}}
2024-08-23 11:35:27 +00:00
{{- if $cover -}}
{{ if and $ctx.Params.coverCaption $isCoverCaptionEnabled }}
2024-08-23 09:29:28 +00:00
<figure>
<!-- Cover image found -->
<img src="{{ $cover }}"
class="post-cover"
alt="{{ .Title | plainify | default " " }}"
2024-08-23 11:35:27 +00:00
title="{{ $ctx.Params.CoverCredit |plainify|default "Cover Image" }}" />
2024-08-23 09:29:28 +00:00
2024-08-23 11:35:27 +00:00
<figcaption class="right">{{ $ctx.Params.coverCaption | safeHTML }}</figcaption>
2024-08-23 09:29:28 +00:00
</figure>
{{ else }}
<!-- Cover image found -->
<img src="{{ $cover }}"
class="post-cover"
alt="{{ .Title | plainify | default " " }}"
2024-08-23 11:35:27 +00:00
title="{{ $ctx.Params.CoverCredit |plainify|default "Cover Image" }}" />
2024-08-23 09:29:28 +00:00
{{ end }}
2022-06-21 13:50:51 +00:00
{{- end }}
2024-08-23 09:29:28 +00:00