hugo-theme-stack-stars/layouts/partials/article/components/header.html
Jimmy Cai cf6502c311
feat: add partialCached to helper/image invocation
Using .RelPermalink as key for cache
2020-09-17 21:52:06 +02:00

20 lines
No EOL
915 B
HTML

<header class="article-header">
{{ $image := partialCached "helper/image" (dict "Context" . "Type" "article") .RelPermalink }}
{{ if $image.exists }}
<div class="article-image">
{{ if $image.resource }}
{{- $tablet := $image.resource.Resize "1024x" -}}
{{- $desktop := $image.resource.Resize "2000x" -}}
<img srcset="{{ $tablet.RelPermalink }} 1024w, {{ $desktop.RelPermalink }} 2000w"
src="{{ $desktop.RelPermalink }}" width="{{ $image.resource.Width }}" height="{{ $image.resource.Height }}" loading="lazy"
alt="Featured image of post {{ .Title }}" />
{{ else }}
<img src="{{ $image.permalink }}" loading="lazy" alt="Featured image of post {{ .Title }}" />
{{ end }}
</div>
{{ end }}
{{ partial "article/components/details" . }}
</header>