feat(helper/image): new image helper (WIP)
This commit is contained in:
@@ -1,17 +1,22 @@
|
||||
<article class="{{ if .Params.image }}has-image{{ end }}">
|
||||
{{ if .Params.image }}
|
||||
{{- $image := partial "helper/image" . -}}
|
||||
{{- $thumbnail := $image.Fill "800x250" -}}
|
||||
{{- $thumbnailRetina := $image.Fill "1600x500" -}}
|
||||
{{ $image := partial "helper/image" . }}
|
||||
|
||||
<div class="article-image">
|
||||
<a href="{{ .Permalink }}">
|
||||
<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>
|
||||
{{ if $image.exists }}
|
||||
<div class="article-image">
|
||||
<a href="{{ .Permalink }}">
|
||||
{{ if $image.local }}
|
||||
{{- $thumbnail := $image.src.Fill "800x250" -}}
|
||||
{{- $thumbnailRetina := $image.src.Fill "1600x500" -}}
|
||||
|
||||
<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 }}" />
|
||||
{{ else }}
|
||||
<img src="{{ $image.src }}" loading="lazy" alt="Featured image of post {{ .Title }}" />
|
||||
{{ end }}
|
||||
</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ partial "article/components/details" . }}
|
||||
|
||||
Reference in New Issue
Block a user