mirror of
https://github.com/adityatelange/hugo-PaperMod.git
synced 2025-01-12 14:33:19 -05:00
Refactor 3
This commit is contained in:
parent
a00f01147c
commit
677dc06194
@ -1,25 +1,27 @@
|
|||||||
{{- with .cxt}} {{/* Apply proper context from dict */}}
|
{{- with .cxt}} {{/* Apply proper context from dict */}}
|
||||||
{{- if (and .Params.cover.image (not $.isHidden)) }}
|
{{- if (and .Params.cover.image (not $.isHidden)) }}
|
||||||
<figure class="entry-cover">
|
<figure class="entry-cover">
|
||||||
{{- $alt := (.Params.cover.alt | default .Params.cover.caption | plainify) }}
|
|
||||||
{{- $loading := cond $.IsSingle "eager" "lazy" }}
|
{{- $loading := cond $.IsSingle "eager" "lazy" }}
|
||||||
{{- $responsiveImages := (.Params.cover.responsiveImages | default site.Params.cover.responsiveImages) | default true }}
|
|
||||||
{{- $addLink := (and site.Params.cover.linkFullImages $.IsSingle) }}
|
{{- $addLink := (and site.Params.cover.linkFullImages $.IsSingle) }}
|
||||||
{{- $pageBundleCover := (.Resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }}
|
{{- $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)) }}
|
{{- $globalResourcesCover := (resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }}
|
||||||
{{- $cover := (or $pageBundleCover $globalResourcesCover)}}
|
{{- $cover := (or $pageBundleCover $globalResourcesCover)}}
|
||||||
|
|
||||||
|
{{- $sizes := (slice "360" "480" "720" "1080" "1500") }}
|
||||||
|
{{- $processableFormats := (slice "jpg" "jpeg" "png" "tif" "bmp" "gif") -}}
|
||||||
|
{{- if hugo.IsExtended -}}
|
||||||
|
{{- $processableFormats = $processableFormats | append "webp" -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
{{- if $addLink }}
|
{{- if $addLink }}
|
||||||
<a href="{{ (path.Join .RelPermalink .Params.cover.image) | absURL }}" target="_blank" rel="noopener noreferrer">
|
<a href="{{ (path.Join .RelPermalink .Params.cover.image) | absURL }}" target="_blank" rel="noopener noreferrer">
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- if $cover -}}{{/* i.e it is present in page bundle */}}
|
{{- if $cover -}}{{/* i.e it is present in page bundle */}}
|
||||||
{{- $sizes := (slice "360" "480" "720" "1080" "1500") }}
|
|
||||||
{{- $processableFormats := (slice "jpg" "jpeg" "png" "tif" "bmp" "gif") -}}
|
|
||||||
{{- if hugo.IsExtended -}}
|
|
||||||
{{- $processableFormats = $processableFormats | append "webp" -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- $prod := (hugo.IsProduction | or (eq site.Params.env "production")) }}
|
|
||||||
{{- if (and (in $processableFormats $cover.MediaType.SubType) ($responsiveImages) (eq $prod true)) }}
|
{{- if (and (in $processableFormats $cover.MediaType.SubType) ($responsiveImages) (eq $prod true)) }}
|
||||||
<img loading="{{$loading}}" srcset="{{- range $size := $sizes -}}
|
<img loading="{{$loading}}" srcset="{{- range $size := $sizes -}}
|
||||||
{{- if (ge $cover.Width $size) -}}
|
{{- if (ge $cover.Width $size) -}}
|
||||||
|
Loading…
Reference in New Issue
Block a user