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
|
||||
enableCodeCopy = false
|
||||
enableImageLazyLoading = true
|
||||
|
||||
# robots = ""
|
||||
fingerprintAlgorithm = "sha256"
|
||||
|
|
|
@ -11,6 +11,7 @@ autoSwitchAppearance = true
|
|||
|
||||
enableSearch = true
|
||||
enableCodeCopy = true
|
||||
enableImageLazyLoading = true
|
||||
|
||||
# robots = ""
|
||||
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`.|
|
||||
|`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.|
|
||||
|`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.|
|
||||
|`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.|
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
{{ $url := urls.Parse .Destination }}
|
||||
{{ $altText := .Text }}
|
||||
{{ $caption := .Title }}
|
||||
{{ $lazyLoad := $.Page.Site.Params.enableImageLazyLoading | default true }}
|
||||
{{ 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 }}"
|
||||
{{ if $lazyLoad }}
|
||||
loading="lazy"
|
||||
{{ end }}
|
||||
/>
|
||||
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
|
||||
</figure>
|
||||
{{ else }}
|
||||
|
@ -32,12 +40,22 @@
|
|||
{{ end }}
|
||||
{{ end }}
|
||||
alt="{{ $altText }}"
|
||||
{{ if $lazyLoad }}
|
||||
loading="lazy"
|
||||
{{ end }}
|
||||
/>
|
||||
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
|
||||
</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 }}"
|
||||
{{ if $lazyLoad }}
|
||||
loading="lazy"
|
||||
{{ end }}
|
||||
/>
|
||||
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
|
||||
</figure>
|
||||
{{ end }}
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
{{ end }}
|
||||
{{ end }}
|
||||
alt="{{ $.Params.featureAlt | default $.Params.coverAlt | default "" }}"
|
||||
{{ if $.Site.Params.enableImageLazyLoading | default true }}
|
||||
loading="lazy"
|
||||
{{ end }}
|
||||
/>
|
||||
{{ with $.Params.coverCaption }}
|
||||
<figcaption class="mb-6 -mt-3 text-center">{{ . | markdownify }}</figcaption>
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
160w, {{- (.Fill "320x240 smart").RelPermalink }} 2x"
|
||||
src="{{ (.Fill "160x120 smart").RelPermalink }}"
|
||||
{{ end }}
|
||||
{{ if $.Site.Params.enableImageLazyLoading | default true }}
|
||||
loading="lazy"
|
||||
{{ end }}
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
height="96"
|
||||
alt="{{ $.Site.Author.name | default "Author" }}"
|
||||
src="{{ $authorImage.RelPermalink }}"
|
||||
{{ if $.Site.Params.enableImageLazyLoading | default true }}
|
||||
loading="lazy"
|
||||
{{ end }}
|
||||
/>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
height="144"
|
||||
alt="{{ $.Site.Author.name | default "Author" }}"
|
||||
src="{{ $authorImage.RelPermalink }}"
|
||||
{{ if $.Site.Params.enableImageLazyLoading | default true }}
|
||||
loading="lazy"
|
||||
{{ end }}
|
||||
/>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
height="{{ div $logo.Height 2 }}"
|
||||
class="max-h-[10rem] max-w-[10rem] object-scale-down object-left{{ if $logo_dark }} hidden dark:flex{{ end }}"
|
||||
alt="{{ .Site.Title }}"
|
||||
{{ if .Site.Params.enableImageLazyLoading | default true }}
|
||||
loading="lazy"
|
||||
{{ end }}
|
||||
/>
|
||||
{{- if $logo_dark }}
|
||||
<img
|
||||
|
@ -17,6 +20,9 @@
|
|||
height="{{ div $logo_dark.Height 2 }}"
|
||||
class="max-h-[10rem] max-w-[10rem] object-scale-down object-left dark:hidden"
|
||||
alt="{{ .Site.Title }}"
|
||||
{{ if .Site.Params.enableImageLazyLoading | default true }}
|
||||
loading="lazy"
|
||||
{{ end }}
|
||||
/>
|
||||
{{- end}}
|
||||
</a>
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
<img
|
||||
class="mx-auto my-0 rounded-md"
|
||||
alt="{{ $altText }}"
|
||||
{{ if .Site.Params.enableImageLazyLoading | default true }}
|
||||
loading="lazy"
|
||||
{{ end }}
|
||||
{{ if findRE "^https?" $url.Scheme }}
|
||||
src="{{ $url.String }}"
|
||||
{{ else }}
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
{{- if or (.Get "alt") (.Get "caption") }}
|
||||
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify | plainify }}{{ end }}"
|
||||
{{- end -}}
|
||||
{{ if .Site.Params.enableImageLazyLoading | default true }}
|
||||
loading="lazy"
|
||||
{{ end }}
|
||||
width="100%"
|
||||
height="auto"
|
||||
style="max-width:{{ div $image.Width 2 }}px; max-height:{{ div $image.Height 2 }}px;"
|
||||
|
|
Loading…
Reference in New Issue