From 54bf5ca168f38b6327ab7e8e6dd1fe5730baa16c Mon Sep 17 00:00:00 2001 From: JamesFlare1212 Date: Tue, 15 Apr 2025 14:54:07 -0400 Subject: [PATCH] update to FixIt 0.3.18 --- README.md | 4 +- config/_default/hugo.toml | 2 +- layouts/partials/plugin/image.html | 115 +++++++++++++++++++++++++++++ themes/FixIt | 2 +- themes/component-projects | 2 +- 5 files changed, 120 insertions(+), 5 deletions(-) create mode 100644 layouts/partials/plugin/image.html diff --git a/README.md b/README.md index 146484a..1a1a00d 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ Then, install Hugo. For Linux: ```bash -wget https://github.com/gohugoio/hugo/releases/download/v0.141.0/hugo_extended_0.141.0_linux-amd64.deb -dpkg -i hugo_extended_0.141.0_linux-amd64.deb +wget https://github.com/gohugoio/hugo/releases/download/v0.146.0/hugo_extended_0.146.0_linux-amd64.deb +sudo dpkg -i hugo_extended_0.146.0_linux-amd64.deb ``` For MacOS: diff --git a/config/_default/hugo.toml b/config/_default/hugo.toml index aea489a..12d4f3a 100644 --- a/config/_default/hugo.toml +++ b/config/_default/hugo.toml @@ -168,7 +168,7 @@ enableEmoji = true # ------------------------------------------------------------------------------------- [privacy] - [privacy.twitter] + [privacy.x] enableDNT = true [privacy.youtube] privacyEnhanced = true diff --git a/layouts/partials/plugin/image.html b/layouts/partials/plugin/image.html new file mode 100644 index 0000000..3b85d28 --- /dev/null +++ b/layouts/partials/plugin/image.html @@ -0,0 +1,115 @@ +{{- /* + deprecated: image-legacy.html + TODO delete this file in the next minor release + */ -}} + {{- $params := partial "function/params.html" -}} + {{- $class := .Class | default "" -}} + {{- $style := "" -}} + {{- $loading := .Loading | default "lazy" -}} + {{- $onload := "" -}} + {{- $onerror := "" -}} + {{- $cacheRemoteImages := $params.cacheRemoteImages -}} + {{- $suffixList := slice ".jpeg" ".jpg" ".png" ".gif" ".bmp" ".tif" ".tiff" ".webp" -}} + {{- $responsive := .Responsive -}} + + {{- if hasPrefix .Src "data:image" -}} + {{- $responsive = false -}} + {{- end -}} + + {{- /* handle for default size image */ -}} + {{- $src := .Src -}} + {{- $suffixValid := dict "Path" $src "Suffixes" $suffixList | partial "function/suffix-validation.html" -}} + {{- with dict "Path" $src "Resources" .Resources "CacheRemoteImages" $cacheRemoteImages.enable | partial "function/resource.html" -}} + {{- $url := urls.Parse $src -}} + {{- if not $url.Host | or $cacheRemoteImages.replace -}} + {{- $src = .RelPermalink -}} + {{- end -}} + {{- /* only available for image resources that are raster images */ -}} + {{- if (eq .ResourceType "image") | and $suffixValid | and $responsive -}} + {{- $style = printf "--width: %vpx;--aspect-ratio: %v / %v;" .Width .Width .Height | safeHTMLAttr -}} + {{- end -}} + {{- end -}} + + {{- $srcSmall := .SrcSmall | default $src -}} + {{- $srcMedium := $src -}} + {{- $srcLarge := .SrcLarge | default $src -}} + + {{- if $responsive }} + {{- /* handle for small size image */ -}} + {{- $suffixValidSmall := dict "Path" $srcSmall "Suffixes" $suffixList | partial "function/suffix-validation.html" -}} + {{- with dict "Path" .SrcSmall "Resources" .Resources "CacheRemoteImages" $cacheRemoteImages.enable | partial "function/resource.html" -}} + {{- $url := urls.Parse $.SrcSmall -}} + {{- if not $url.Host | or $cacheRemoteImages.replace -}} + {{- $srcSmall = .RelPermalink -}} + {{- end -}} + {{- if (eq .ResourceType "image") | and $suffixValidSmall -}} + {{- $style = printf "%v--width-small: %vpx;--aspect-ratio-small: %v / %v;" $style .Width .Width .Height | safeHTMLAttr -}} + {{- end -}} + {{- end -}} + + {{- /* handle for large size image */ -}} + {{- $suffixValidLarge := dict "Path" $srcLarge "Suffixes" $suffixList | partial "function/suffix-validation.html" -}} + {{- with dict "Path" .SrcLarge "Resources" .Resources "CacheRemoteImages" $cacheRemoteImages.enable | partial "function/resource.html" -}} + {{- $url := urls.Parse $.SrcLarge -}} + {{- if not $url.Host | or $cacheRemoteImages.replace -}} + {{- $srcLarge = .RelPermalink -}} + {{- end -}} + {{- if (eq .ResourceType "image") | and $suffixValidLarge -}} + {{- $style = printf "%v--width-large: %vpx;--aspect-ratio-large: %v / %v;" $style .Width .Width .Height | safeHTMLAttr -}} + {{- end -}} + {{- end -}} + + {{- /* handle for invalid suffix */ -}} + {{- if not $suffixValid | and $src -}} + {{- $class = printf "%v suffix-invalid" $class -}} + {{- end -}} + {{- if not $suffixValidSmall | and $srcSmall -}} + {{- $class = printf "%v suffix-invalid__small" $class -}} + {{- end -}} + {{- if not $suffixValidLarge | and $srcLarge -}} + {{- $class = printf "%v suffix-invalid__large" $class -}} + {{- end -}} + + {{- /* set image srcset */ -}} + {{- if (eq $src $srcSmall) | and (eq $src $srcLarge) -}} + {{- $srcSmall = printf (cond (strings.Contains $srcSmall "?") "%v&size=small" "%v?size=small") $srcSmall -}} + {{- $srcMedium = printf (cond (strings.Contains $srcMedium "?") "%v&size=medium" "%v?size=medium") $srcMedium -}} + {{- $srcLarge = printf (cond (strings.Contains $srcLarge "?") "%v&size=large" "%v?size=large") $srcLarge -}} + {{- end -}} + {{- end -}} + + {{- /* set image alt and caption */ -}} + {{- $alt := .Alt | default $src -}} + {{- $caption := .Caption | default $alt -}} + + {{- /* set image lazy loading */ -}} + {{- /* for details, see https://lruihao.cn/posts/native-img-loading-lazy/ */ -}} + {{- if eq $loading "lazy" -}} + {{- /* TODO move to theme.js */ -}} + {{- $commonScript := "this.title=this.dataset.title;for(const i of ['style', 'data-title','onerror','onload']){this.removeAttribute(i);}" -}} + {{- $onload = printf " onload=\"%vthis.dataset.lazyloaded='';\"" $commonScript | safeHTMLAttr -}} + {{- $onerror = printf " onerror=\"%v\"" $commonScript | safeHTMLAttr -}} + {{- $style = printf " style=\"%vbackground: url(%v) no-repeat center;\"" $style (resources.Get "images/loading.svg" | minify).RelPermalink | safeHTMLAttr -}} + {{- end -}} + + {{- /* structure of lightgallery or img */ -}} + {{- if .Linked -}} + + {{- end -}} + {{ $alt }} + {{- if .Linked -}} + + {{- end -}} + \ No newline at end of file diff --git a/themes/FixIt b/themes/FixIt index 3f66669..c2dc17e 160000 --- a/themes/FixIt +++ b/themes/FixIt @@ -1 +1 @@ -Subproject commit 3f6666958135fa8b9c8a5e5e153854e4f44dbeee +Subproject commit c2dc17e9e093373139806190f75cfea314581275 diff --git a/themes/component-projects b/themes/component-projects index 15df91a..b1dcfac 160000 --- a/themes/component-projects +++ b/themes/component-projects @@ -1 +1 @@ -Subproject commit 15df91adccae4c9ada36a3634f2f62fd6c543659 +Subproject commit b1dcfac0ff484bc852942cebfc0f6291b825afba