mirror of https://github.com/jpanther/congo.git
🔀 Merge pull request #552 from tomy0000000/lazy-load-image-by-default
✨ feat: Lazy load image by default
pull/575/head
commit
4138925778
|
@ -11,6 +11,7 @@ autoSwitchAppearance = true
|
||||||
|
|
||||||
enableSearch = false
|
enableSearch = false
|
||||||
enableCodeCopy = false
|
enableCodeCopy = false
|
||||||
|
enableImageLazyLoading = true
|
||||||
|
|
||||||
# robots = ""
|
# robots = ""
|
||||||
fingerprintAlgorithm = "sha256"
|
fingerprintAlgorithm = "sha256"
|
||||||
|
|
|
@ -11,6 +11,7 @@ autoSwitchAppearance = true
|
||||||
|
|
||||||
enableSearch = true
|
enableSearch = true
|
||||||
enableCodeCopy = true
|
enableCodeCopy = true
|
||||||
|
enableImageLazyLoading = true
|
||||||
|
|
||||||
# robots = ""
|
# robots = ""
|
||||||
fingerprintAlgorithm = "sha256"
|
fingerprintAlgorithm = "sha256"
|
||||||
|
|
|
@ -129,6 +129,7 @@ Many of the article defaults here can be overridden on a per article basis by sp
|
||||||
|`autoSwitchAppearance`|`true`|Whether the theme appearance automatically switches based upon the visitor's operating system preference. Set to `false` to force the site to always use the `defaultAppearance`.|
|
|`autoSwitchAppearance`|`true`|Whether the theme appearance automatically switches based upon the visitor's operating system preference. Set to `false` to force the site to always use the `defaultAppearance`.|
|
||||||
|`enableSearch`|`false`|Whether site search is enabled. Set to `true` to enable search functionality. Note that the search feature depends on the `outputs.home` setting in the [site configuration](#site-configuration) being set correctly.|
|
|`enableSearch`|`false`|Whether site search is enabled. Set to `true` to enable search functionality. Note that the search feature depends on the `outputs.home` setting in the [site configuration](#site-configuration) being set correctly.|
|
||||||
|`enableCodeCopy`|`false`|Whether copy-to-clipboard buttons are enabled for `<code>` blocks. The `highlight.noClasses` parameter must be set to `false` for code copy to function correctly. Read more about [other configuration files](#other-configuration-files) below.|
|
|`enableCodeCopy`|`false`|Whether copy-to-clipboard buttons are enabled for `<code>` blocks. The `highlight.noClasses` parameter must be set to `false` for code copy to function correctly. Read more about [other configuration files](#other-configuration-files) below.|
|
||||||
|
|`enableImageLazyLoading`|`true`|Whether image should be lazy loading.|
|
||||||
|`robots`|_Not set_|String that indicates how robots should handle your site. If set, it will be output in the page head. Refer to [Google's docs](https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#directives) for valid values.|
|
|`robots`|_Not set_|String that indicates how robots should handle your site. If set, it will be output in the page head. Refer to [Google's docs](https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#directives) for valid values.|
|
||||||
|`fingerprintAlgorithm`|`"sha256"`|String that indicates which hashing algorithm is used when fingerprinting assets. Valid options include `md5`, `sha256`, `sha384` and `sha512`.|
|
|`fingerprintAlgorithm`|`"sha256"`|String that indicates which hashing algorithm is used when fingerprinting assets. Valid options include `md5`, `sha256`, `sha384` and `sha512`.|
|
||||||
|`header.layout`|`"basic"`|The layout of the page header and menu. Valid values are `basic`, `hamburger`, `hybrid` or `custom`. When set to `custom`, you must provide your own layout by creating a `/layouts/partials/header/custom.html` file.|
|
|`header.layout`|`"basic"`|The layout of the page header and menu. Valid values are `basic`, `hamburger`, `hybrid` or `custom`. When set to `custom`, you must provide your own layout by creating a `/layouts/partials/header/custom.html` file.|
|
||||||
|
|
|
@ -1,9 +1,17 @@
|
||||||
{{ $url := urls.Parse .Destination }}
|
{{ $url := urls.Parse .Destination }}
|
||||||
{{ $altText := .Text }}
|
{{ $altText := .Text }}
|
||||||
{{ $caption := .Title }}
|
{{ $caption := .Title }}
|
||||||
|
{{ $lazyLoad := $.Page.Site.Params.enableImageLazyLoading | default true }}
|
||||||
{{ 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 }}" />
|
<img
|
||||||
|
class="mx-auto my-0 rounded-md"
|
||||||
|
src="{{ $url.String }}"
|
||||||
|
alt="{{ $altText }}"
|
||||||
|
{{ if $lazyLoad }}
|
||||||
|
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,12 +40,22 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
alt="{{ $altText }}"
|
alt="{{ $altText }}"
|
||||||
|
{{ if $lazyLoad }}
|
||||||
|
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 }}" />
|
<img
|
||||||
|
class="mx-auto my-0 rounded-md"
|
||||||
|
src="{{ $url.String }}"
|
||||||
|
alt="{{ $altText }}"
|
||||||
|
{{ if $lazyLoad }}
|
||||||
|
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,6 +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"
|
||||||
|
{{ 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,6 +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"
|
||||||
|
{{ end }}
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,6 +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"
|
||||||
|
{{ end }}
|
||||||
/>
|
/>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -14,6 +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"
|
||||||
|
{{ end }}
|
||||||
/>
|
/>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -9,6 +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"
|
||||||
|
{{ end }}
|
||||||
/>
|
/>
|
||||||
{{- if $logo_dark }}
|
{{- if $logo_dark }}
|
||||||
<img
|
<img
|
||||||
|
@ -17,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,6 +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"
|
||||||
|
{{ end }}
|
||||||
{{ if findRE "^https?" $url.Scheme }}
|
{{ if findRE "^https?" $url.Scheme }}
|
||||||
src="{{ $url.String }}"
|
src="{{ $url.String }}"
|
||||||
{{ else }}
|
{{ else }}
|
||||||
|
|
|
@ -8,6 +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"
|
||||||
|
{{ 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