feat(helper/image): new image helper (WIP)
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
{{ $i := .Params.image }}
|
||||
{{ $image := partial "helper/image" . }}
|
||||
{{ $context := . }}
|
||||
|
||||
<div class="article-details">
|
||||
{{ with $categories := .Params.categories }}
|
||||
<header class="article-category">
|
||||
{{ range $categories }}
|
||||
{{ if $i }}
|
||||
{{- $image := partial "helper/image" $context | resources.Fingerprint "md5" -}}
|
||||
{{- $20x := $image.Fill "20x20 smart" -}}
|
||||
{{ if and $image.exists $image.local }}
|
||||
{{- $imageRaw := $image.src | resources.Fingerprint "md5" -}}
|
||||
{{- $20x := $imageRaw.Fill "20x20 smart" -}}
|
||||
<a href="/categories/{{ . | urlize }}" class="color-tag"
|
||||
data-image="{{ $20x.RelPermalink }}" data-key="{{ $context.Slug }}" data-hash="{{ $image.Data.Integrity }}">{{ . | humanize }}</a>
|
||||
data-image="{{ $20x.RelPermalink }}" data-key="{{ $context.Slug }}" data-hash="{{ $imageRaw.Data.Integrity }}">{{ . | humanize }}</a>
|
||||
{{ else }}
|
||||
<a href="/categories/{{ . | urlize }}">{{ . | humanize }}</a>
|
||||
{{ end }}
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
<header class="article-header">
|
||||
{{ if .Params.image }}
|
||||
{{- $image := partial "helper/image" . -}}
|
||||
{{ $image := partial "helper/image" . }}
|
||||
|
||||
{{- $tablet := $image.Resize "1024x" -}}
|
||||
{{- $desktop := $image.Resize "2000x" -}}
|
||||
{{ if $image.exists }}
|
||||
<div class="article-image">
|
||||
{{ if $image.local }}
|
||||
{{- $tablet := $image.src.Resize "1024x" -}}
|
||||
{{- $desktop := $image.src.Resize "2000x" -}}
|
||||
|
||||
<div class="article-image">
|
||||
<img srcset="{{ $tablet.RelPermalink }} 1024w, {{ $desktop.RelPermalink }} 2000w"
|
||||
src="{{ $desktop.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}"
|
||||
loading="lazy"
|
||||
alt="Featured image of post {{ .Title }}" />
|
||||
</div>
|
||||
<img srcset="{{ $tablet.RelPermalink }} 1024w, {{ $desktop.RelPermalink }} 2000w"
|
||||
src="{{ $desktop.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}" loading="lazy"
|
||||
alt="Featured image of post {{ .Title }}" />
|
||||
{{ else }}
|
||||
<img src="{{ $image.src }}" loading="lazy" alt="Featured image of post {{ .Title }}" />
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ partial "article/components/details" . }}
|
||||
|
||||
Reference in New Issue
Block a user