feat: Add specific render to add lazy loading

This commit is contained in:
Simon 2021-10-21 22:25:55 +02:00
parent 2e74dbfa2b
commit ad3107622a
1 changed files with 10 additions and 0 deletions

View File

@ -0,0 +1,10 @@
{{/*
S'il n'y a pas de / dans l'url d'une image alors on ajoute le path de l'article
*/}}
{{ $path := cond (in .Destination "/") .Destination (path.Join "/" .Page.File.Dir .Destination) }}
{{ $image := .Page.Resources.GetMatch (printf "*%s*" .Destination) }}
{{ with $image }}
{{ $resized := $image.Resize "610x q100 webp" }}
{{ $path = $resized.RelPermalink }}
{{ end }}
<img src="{{ $path | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}"{{ end }} loading="lazy" />