feat(helper/image): new image helper (WIP)

This commit is contained in:
Jimmy Cai
2020-09-10 18:53:36 +02:00
parent 62b0da64df
commit 28c06ef8ae
7 changed files with 100 additions and 49 deletions
@@ -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 }}