From 0d4fe03a45432c4efbac67767ffdeed056eb196b Mon Sep 17 00:00:00 2001 From: Tomy Hsieh Date: Sat, 27 May 2023 05:37:02 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=20fix:=20Syntax=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layouts/_default/_markup/render-image.html | 7 ++++--- layouts/_default/single.html | 2 +- layouts/partials/article-link.html | 2 +- layouts/partials/author.html | 2 +- layouts/partials/home/profile.html | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index c2b220ad..e2009a06 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,13 +1,14 @@ {{ $url := urls.Parse .Destination }} {{ $altText := .Text }} {{ $caption := .Title }} +{{ $lazyLoad := $.Page.Site.Params.enableImageLazyLoading | default true }} {{ if findRE "^https?" $url.Scheme }}
{{ $altText }} @@ -39,7 +40,7 @@ {{ end }} {{ end }} alt="{{ $altText }}" - {{ if .Site.Params.enableImageLazyLoading | default true }} + {{ if $lazyLoad }} loading="lazy" {{ end }} /> @@ -51,7 +52,7 @@ class="mx-auto my-0 rounded-md" src="{{ $url.String }}" alt="{{ $altText }}" - {{ if .Site.Params.enableImageLazyLoading | default true }} + {{ if $lazyLoad }} loading="lazy" {{ end }} /> diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 9f3c52cd..90c5110b 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -31,7 +31,7 @@ {{ end }} {{ end }} alt="{{ $.Params.featureAlt | default $.Params.coverAlt | default "" }}" - {{ if .Site.Params.enableImageLazyLoading | default true }} + {{ if $.Site.Params.enableImageLazyLoading | default true }} loading="lazy" {{ end }} /> diff --git a/layouts/partials/article-link.html b/layouts/partials/article-link.html index f934bae0..689bdf71 100644 --- a/layouts/partials/article-link.html +++ b/layouts/partials/article-link.html @@ -23,7 +23,7 @@ 160w, {{- (.Fill "320x240 smart").RelPermalink }} 2x" src="{{ (.Fill "160x120 smart").RelPermalink }}" {{ end }} - {{ if .Site.Params.enableImageLazyLoading | default true }} + {{ if $.Site.Params.enableImageLazyLoading | default true }} loading="lazy" {{ end }} /> diff --git a/layouts/partials/author.html b/layouts/partials/author.html index ca7b17bc..2d29aa82 100644 --- a/layouts/partials/author.html +++ b/layouts/partials/author.html @@ -10,7 +10,7 @@ height="96" alt="{{ $.Site.Author.name | default "Author" }}" src="{{ $authorImage.RelPermalink }}" - {{ if .Site.Params.enableImageLazyLoading | default true }} + {{ if $.Site.Params.enableImageLazyLoading | default true }} loading="lazy" {{ end }} /> diff --git a/layouts/partials/home/profile.html b/layouts/partials/home/profile.html index 324e31f1..24fb6f63 100644 --- a/layouts/partials/home/profile.html +++ b/layouts/partials/home/profile.html @@ -14,7 +14,7 @@ height="144" alt="{{ $.Site.Author.name | default "Author" }}" src="{{ $authorImage.RelPermalink }}" - {{ if .Site.Params.enableImageLazyLoading | default true }} + {{ if $.Site.Params.enableImageLazyLoading | default true }} loading="lazy" {{ end }} />