feat: Lazy load image in all places

This commit is contained in:
Tomy Hsieh
2023-05-27 05:26:57 +08:00
parent 159aaae1e5
commit adf7f6f224
8 changed files with 9 additions and 2 deletions
+2 -2
View File
@@ -3,7 +3,7 @@
{{ $caption := .Title }}
{{ if findRE "^https?" $url.Scheme }}
<figure>
<img class="mx-auto my-0 rounded-md" src="{{ $url.String }}" alt="{{ $altText }}" />
<img class="mx-auto my-0 rounded-md" src="{{ $url.String }}" alt="{{ $altText }}" loading="lazy" />
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
</figure>
{{ else }}
@@ -38,7 +38,7 @@
</figure>
{{ else }}
<figure>
<img class="mx-auto my-0 rounded-md" src="{{ $url.String }}" alt="{{ $altText }}" />
<img class="mx-auto my-0 rounded-md" src="{{ $url.String }}" alt="{{ $altText }}" loading="lazy" />
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
</figure>
{{ end }}
+1
View File
@@ -31,6 +31,7 @@
{{ end }}
{{ end }}
alt="{{ $.Params.featureAlt | default $.Params.coverAlt | default "" }}"
loading="lazy"
/>
{{ with $.Params.coverCaption }}
<figcaption class="mb-6 -mt-3 text-center">{{ . | markdownify }}</figcaption>