add configuration option

pull/647/head
stereobooster 2023-09-13 09:46:11 +02:00
parent d37a633509
commit afa25640c3
2 changed files with 3 additions and 1 deletions

View File

@ -13,6 +13,7 @@ enableSearch = true
enableCodeCopy = true enableCodeCopy = true
enableImageLazyLoading = true enableImageLazyLoading = true
enableWebp = true enableWebp = true
enableLqip = true
# robots = "" # robots = ""
fingerprintAlgorithm = "sha256" fingerprintAlgorithm = "sha256"

View File

@ -4,6 +4,7 @@
{{ $lazyLoad := .context.Page.Site.Params.enableImageLazyLoading | default true }} {{ $lazyLoad := .context.Page.Site.Params.enableImageLazyLoading | default true }}
{{ $webp := .context.Page.Site.Params.enableWebp | default true }} {{ $webp := .context.Page.Site.Params.enableWebp | default true }}
{{ $lqip := .context.Page.Site.Params.enableLqip | default true }}
{{ if findRE "^https?" $url.Scheme }} {{ if findRE "^https?" $url.Scheme }}
<img <img
@ -22,7 +23,7 @@
{{ $resource = resources.Get ($url.String) }} {{ $resource = resources.Get ($url.String) }}
{{ end }} {{ end }}
{{ with $resource }} {{ with $resource }}
{{ if ne .MediaType.SubType "svg" }} {{ if (and (ne .MediaType.SubType "svg") $lqip) }}
{{ $lqip := (.Resize "20x webp").Content | base64Encode }} {{ $lqip := (.Resize "20x webp").Content | base64Encode }}
<picture <picture
style="background: url(data:image/webp;base64,{{ $lqip }}); background-size: cover" style="background: url(data:image/webp;base64,{{ $lqip }}); background-size: cover"