feat(article list/default): better thumbnail

This commit is contained in:
Jimmy Cai 2020-09-06 19:51:16 +02:00
parent 2ab49f97ee
commit 7f3d906f24
No known key found for this signature in database
GPG key ID: 3EA408E527F37B18

View file

@ -1,12 +1,14 @@
<article class="{{ if .Params.image }}has-image{{ end }}">
{{ if .Params.image }}
{{- $image := partial "helper/image" . -}}
{{- $thumbnailNotDesktop := $image.Resize "x500 smart" -}}
{{- $thumbnail := $image.Fill "800x250" -}}
{{- $thumbnailRetina := $image.Fill "1600x500" -}}
<div class="article-image">
<a href="{{ .Permalink }}">
<img src="{{ $thumbnailNotDesktop.RelPermalink }}"
width="{{ $thumbnailNotDesktop.Width }}" height="{{ $thumbnailNotDesktop.Height }}" loading="lazy"
<img src="{{ $thumbnail.RelPermalink }}"
srcset="{{ $thumbnail.RelPermalink }} 1x, {{ $thumbnailRetina.RelPermalink }} 2x"
width="{{ $thumbnail.Width }}" height="{{ $thumbnail.Height }}" loading="lazy"
alt="Featured image of post {{ .Title }}" />
</a>
</div>