From 86b0d0c422e34c38837b5b5495ad6d295d0e73d2 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Mon, 1 Sep 2025 11:27:12 -0700 Subject: Squashed 'themes/PaperMod/' content from commit 5a46517 git-subtree-dir: themes/PaperMod git-subtree-split: 5a4651783fa9159123d947bd3511b355146d4797 --- layouts/partials/cover.html | 65 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 layouts/partials/cover.html (limited to 'layouts/partials/cover.html') diff --git a/layouts/partials/cover.html b/layouts/partials/cover.html new file mode 100644 index 0000000..9c1f9ea --- /dev/null +++ b/layouts/partials/cover.html @@ -0,0 +1,65 @@ +{{- with .cxt}} {{/* Apply proper context from dict */}} +{{- if (and .Params.cover.image (not $.isHidden)) }} +
+ {{- $loading := cond $.IsSingle "eager" "lazy" }} + {{- $addLink := (and site.Params.cover.linkFullImages $.IsSingle) }} + {{- $prod := (hugo.IsProduction | or (eq site.Params.env "production")) }} + {{- $alt := (.Params.cover.alt | default .Params.cover.caption | plainify) }} + {{- $responsiveImages := (.Params.cover.responsiveImages | default site.Params.cover.responsiveImages) | default true }} + + {{- $pageBundleCover := (.Resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }} + {{- $globalResourcesCover := (resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }} + {{- $cover := (or $pageBundleCover $globalResourcesCover)}} + {{- /* We are not using the .Param.cover.relative to decide the location of image */}} + {{- /* If we have the image in pageBundle or globalResources we can process the image */}} + + {{- $sizes := (slice "360" "480" "720" "1080" "1500") }} + {{- $processableFormats := (slice "jpg" "jpeg" "png" "tif" "bmp" "gif") -}} + {{- if hugo.IsExtended -}} + {{- $processableFormats = $processableFormats | append "webp" -}} + {{- end -}} + + {{- $imgdl := (.Params.cover.image) | absURL }} + {{- if $cover -}} + {{- $imgdl = $cover.Permalink }} + {{- end -}} + + {{- if $addLink }} + + {{- end }} + + {{- if $cover -}} + {{/* i.e it is present in page bundle */}} + {{- if (and (in $processableFormats $cover.MediaType.SubType) ($responsiveImages) (eq $prod true)) }} + {{ $alt }} + {{- else }}{{/* Unprocessable image or responsive images disabled */}} + {{ $alt }} + {{- end }} + {{- else }} + {{- /* For absolute urls and external links, no img processing here */}} + {{ $alt }} + {{- end }} + + {{- if $addLink }} + + {{- end -}} + + {{- /* Display Caption */}} + {{- if $.IsSingle }} + {{ with .Params.cover.caption -}} +
{{ . | markdownify }}
+ {{- end }} + {{- end }} +
+{{- end }}{{/* End image */}} +{{- end -}}{{/* End context */ -}} -- cgit v1.3.1