mirror of https://github.com/jpanther/congo.git
✨ feat: Make image lazy load togglable
parent
adf7f6f224
commit
88c73a3aae
|
@ -11,6 +11,7 @@ autoSwitchAppearance = true
|
||||||
|
|
||||||
enableSearch = false
|
enableSearch = false
|
||||||
enableCodeCopy = false
|
enableCodeCopy = false
|
||||||
|
enableImageLazyLoading = true
|
||||||
|
|
||||||
# robots = ""
|
# robots = ""
|
||||||
fingerprintAlgorithm = "sha256"
|
fingerprintAlgorithm = "sha256"
|
||||||
|
|
|
@ -3,7 +3,14 @@
|
||||||
{{ $caption := .Title }}
|
{{ $caption := .Title }}
|
||||||
{{ if findRE "^https?" $url.Scheme }}
|
{{ if findRE "^https?" $url.Scheme }}
|
||||||
<figure>
|
<figure>
|
||||||
<img class="mx-auto my-0 rounded-md" src="{{ $url.String }}" alt="{{ $altText }}" loading="lazy" />
|
<img
|
||||||
|
class="mx-auto my-0 rounded-md"
|
||||||
|
src="{{ $url.String }}"
|
||||||
|
alt="{{ $altText }}"
|
||||||
|
{{ if .Site.Params.enableImageLazyLoading | default true }}
|
||||||
|
loading="lazy"
|
||||||
|
{{ end }}
|
||||||
|
/>
|
||||||
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
|
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
|
||||||
</figure>
|
</figure>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
|
@ -32,13 +39,22 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
alt="{{ $altText }}"
|
alt="{{ $altText }}"
|
||||||
|
{{ if .Site.Params.enableImageLazyLoading | default true }}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
|
{{ end }}
|
||||||
/>
|
/>
|
||||||
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
|
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
|
||||||
</figure>
|
</figure>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<figure>
|
<figure>
|
||||||
<img class="mx-auto my-0 rounded-md" src="{{ $url.String }}" alt="{{ $altText }}" loading="lazy" />
|
<img
|
||||||
|
class="mx-auto my-0 rounded-md"
|
||||||
|
src="{{ $url.String }}"
|
||||||
|
alt="{{ $altText }}"
|
||||||
|
{{ if .Site.Params.enableImageLazyLoading | default true }}
|
||||||
|
loading="lazy"
|
||||||
|
{{ end }}
|
||||||
|
/>
|
||||||
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
|
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
|
||||||
</figure>
|
</figure>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -31,7 +31,9 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
alt="{{ $.Params.featureAlt | default $.Params.coverAlt | default "" }}"
|
alt="{{ $.Params.featureAlt | default $.Params.coverAlt | default "" }}"
|
||||||
|
{{ if .Site.Params.enableImageLazyLoading | default true }}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
|
{{ end }}
|
||||||
/>
|
/>
|
||||||
{{ with $.Params.coverCaption }}
|
{{ with $.Params.coverCaption }}
|
||||||
<figcaption class="mb-6 -mt-3 text-center">{{ . | markdownify }}</figcaption>
|
<figcaption class="mb-6 -mt-3 text-center">{{ . | markdownify }}</figcaption>
|
||||||
|
|
|
@ -23,7 +23,9 @@
|
||||||
160w, {{- (.Fill "320x240 smart").RelPermalink }} 2x"
|
160w, {{- (.Fill "320x240 smart").RelPermalink }} 2x"
|
||||||
src="{{ (.Fill "160x120 smart").RelPermalink }}"
|
src="{{ (.Fill "160x120 smart").RelPermalink }}"
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ if .Site.Params.enableImageLazyLoading | default true }}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
|
{{ end }}
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
height="96"
|
height="96"
|
||||||
alt="{{ $.Site.Author.name | default "Author" }}"
|
alt="{{ $.Site.Author.name | default "Author" }}"
|
||||||
src="{{ $authorImage.RelPermalink }}"
|
src="{{ $authorImage.RelPermalink }}"
|
||||||
|
{{ if .Site.Params.enableImageLazyLoading | default true }}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
|
{{ end }}
|
||||||
/>
|
/>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
height="144"
|
height="144"
|
||||||
alt="{{ $.Site.Author.name | default "Author" }}"
|
alt="{{ $.Site.Author.name | default "Author" }}"
|
||||||
src="{{ $authorImage.RelPermalink }}"
|
src="{{ $authorImage.RelPermalink }}"
|
||||||
|
{{ if .Site.Params.enableImageLazyLoading | default true }}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
|
{{ end }}
|
||||||
/>
|
/>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
height="{{ div $logo.Height 2 }}"
|
height="{{ div $logo.Height 2 }}"
|
||||||
class="max-h-[10rem] max-w-[10rem] object-scale-down object-left{{ if $logo_dark }} hidden dark:flex{{ end }}"
|
class="max-h-[10rem] max-w-[10rem] object-scale-down object-left{{ if $logo_dark }} hidden dark:flex{{ end }}"
|
||||||
alt="{{ .Site.Title }}"
|
alt="{{ .Site.Title }}"
|
||||||
|
{{ if .Site.Params.enableImageLazyLoading | default true }}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
|
{{ end }}
|
||||||
/>
|
/>
|
||||||
{{- if $logo_dark }}
|
{{- if $logo_dark }}
|
||||||
<img
|
<img
|
||||||
|
@ -18,6 +20,9 @@
|
||||||
height="{{ div $logo_dark.Height 2 }}"
|
height="{{ div $logo_dark.Height 2 }}"
|
||||||
class="max-h-[10rem] max-w-[10rem] object-scale-down object-left dark:hidden"
|
class="max-h-[10rem] max-w-[10rem] object-scale-down object-left dark:hidden"
|
||||||
alt="{{ .Site.Title }}"
|
alt="{{ .Site.Title }}"
|
||||||
|
{{ if .Site.Params.enableImageLazyLoading | default true }}
|
||||||
|
loading="lazy"
|
||||||
|
{{ end }}
|
||||||
/>
|
/>
|
||||||
{{- end}}
|
{{- end}}
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -11,7 +11,9 @@
|
||||||
<img
|
<img
|
||||||
class="mx-auto my-0 rounded-md"
|
class="mx-auto my-0 rounded-md"
|
||||||
alt="{{ $altText }}"
|
alt="{{ $altText }}"
|
||||||
|
{{ if .Site.Params.enableImageLazyLoading | default true }}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
|
{{ end }}
|
||||||
{{ if findRE "^https?" $url.Scheme }}
|
{{ if findRE "^https?" $url.Scheme }}
|
||||||
src="{{ $url.String }}"
|
src="{{ $url.String }}"
|
||||||
{{ else }}
|
{{ else }}
|
||||||
|
|
|
@ -8,7 +8,9 @@
|
||||||
{{- if or (.Get "alt") (.Get "caption") }}
|
{{- if or (.Get "alt") (.Get "caption") }}
|
||||||
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify | plainify }}{{ end }}"
|
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify | plainify }}{{ end }}"
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
{{ if .Site.Params.enableImageLazyLoading | default true }}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
|
{{ end }}
|
||||||
width="100%"
|
width="100%"
|
||||||
height="auto"
|
height="auto"
|
||||||
style="max-width:{{ div $image.Width 2 }}px; max-height:{{ div $image.Height 2 }}px;"
|
style="max-width:{{ div $image.Width 2 }}px; max-height:{{ div $image.Height 2 }}px;"
|
||||||
|
|
Loading…
Reference in New Issue