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
+11 -7
View File
@@ -12,13 +12,17 @@
</footer>
</div>
{{ if .Params.image }}
{{- $image := partial "helper/image" . -}}
{{- $thumbnail := $image.Fill "120x120" -}}
{{ $image := partial "helper/image" . }}
<div class="article-image">
<img src="{{ $thumbnail.RelPermalink }}" width="{{ $thumbnail.Width }}"
height="{{ $thumbnail.Height }}" loading="lazy">
</div>
{{ if $image.exists }}
<div class="article-image">
{{ if $image.local }}
{{- $thumbnail := $image.src.Fill "120x120" -}}
<img src="{{ $thumbnail.RelPermalink }}" width="{{ $thumbnail.Width }}"
height="{{ $thumbnail.Height }}" loading="lazy">
{{ else }}
<img src="{{ $image.src }}" loading="lazy" alt="Featured image of post {{ .Title }}" />
{{ end }}
</div>
{{ end }}
</article>