From 7cb8dcc4a1d3bcc441a1c263759a9cf02f87232d Mon Sep 17 00:00:00 2001 From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com> Date: Thu, 18 Sep 2025 03:50:35 +0800 Subject: [PATCH 01/13] chore(article-link): remove _external-link.html we don't need this anymore --- layouts/partials/article-link/_external-link.html | 5 ----- layouts/partials/article-link/_shortcode.html | 6 +++++- layouts/partials/article-link/card-related.html | 6 +++++- layouts/partials/article-link/card.html | 6 +++++- layouts/partials/article-link/simple.html | 9 ++++++--- 5 files changed, 21 insertions(+), 11 deletions(-) delete mode 100644 layouts/partials/article-link/_external-link.html diff --git a/layouts/partials/article-link/_external-link.html b/layouts/partials/article-link/_external-link.html deleted file mode 100644 index e3e9980d..00000000 --- a/layouts/partials/article-link/_external-link.html +++ /dev/null @@ -1,5 +0,0 @@ -{{ with .Params.externalUrl }} - href="{{ . }}" target="_blank" rel="external" -{{ else }} - href="{{ .RelPermalink }}" -{{- end -}} diff --git a/layouts/partials/article-link/_shortcode.html b/layouts/partials/article-link/_shortcode.html index 511565f0..ef25463e 100644 --- a/layouts/partials/article-link/_shortcode.html +++ b/layouts/partials/article-link/_shortcode.html @@ -69,7 +69,11 @@

{{ $target.Title | emojify }} diff --git a/layouts/partials/article-link/card-related.html b/layouts/partials/article-link/card-related.html index 0bb98641..dc0e49af 100644 --- a/layouts/partials/article-link/card-related.html +++ b/layouts/partials/article-link/card-related.html @@ -52,7 +52,11 @@

{{ .Title | emojify }} diff --git a/layouts/partials/article-link/card.html b/layouts/partials/article-link/card.html index aaaab0c8..636741a0 100644 --- a/layouts/partials/article-link/card.html +++ b/layouts/partials/article-link/card.html @@ -56,7 +56,11 @@

{{ .Title | emojify }} diff --git a/layouts/partials/article-link/simple.html b/layouts/partials/article-link/simple.html index 50924907..7b9fa430 100644 --- a/layouts/partials/article-link/simple.html +++ b/layouts/partials/article-link/simple.html @@ -56,8 +56,7 @@
{{ with $featuredURL }} -
+
{{ $.Title }}

{{ .Title | emojify }} From 4b9e63fd99da2227b5fa16b4234828d40afa60a6 Mon Sep 17 00:00:00 2001 From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com> Date: Thu, 18 Sep 2025 04:13:06 +0800 Subject: [PATCH 02/13] feat(article-link): add support for `hotlinkFeatureImages` --- config/_default/params.toml | 1 + exampleSite/config/_default/params.toml | 1 + .../content/docs/configuration/index.it.md | 1 + .../content/docs/configuration/index.ja.md | 1 + .../content/docs/configuration/index.md | 1 + .../content/docs/configuration/index.zh-cn.md | 1 + layouts/_default/baseof.html | 1 + layouts/partials/article-link/_shortcode.html | 63 +++++++++++++------ .../partials/article-link/card-related.html | 57 +++++++++++------ layouts/partials/article-link/card.html | 57 +++++++++++------ layouts/partials/article-link/simple.html | 57 +++++++++++------ layouts/partials/init.html | 34 ++++++++++ 12 files changed, 199 insertions(+), 76 deletions(-) create mode 100644 layouts/partials/init.html diff --git a/config/_default/params.toml b/config/_default/params.toml index 7f3abf80..c42f194a 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -26,6 +26,7 @@ disableTextInHeader = false # defaultBackgroundImage = "IMAGE.jpg" # used as default for background images # defaultFeaturedImage = "IMAGE.jpg" # used as default for featured images in all articles # defaultSocialImage = "/android-chrome-512x512.png" # used as default for social media sharing (Open Graph and Twitter) +hotlinkFeatureImages = false # highlightCurrentMenuArea = true # smartTOC = true diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 80196217..c075927e 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -26,6 +26,7 @@ disableTextInHeader = false defaultBackgroundImage = "/img/background.svg" defaultFeaturedImage = "/img/featured.svg" defaultSocialImage = "/img/blowfish_banner.png" +hotlinkFeatureImages = false highlightCurrentMenuArea = true smartTOC = true diff --git a/exampleSite/content/docs/configuration/index.it.md b/exampleSite/content/docs/configuration/index.it.md index 270ebfd5..ce09b474 100644 --- a/exampleSite/content/docs/configuration/index.it.md +++ b/exampleSite/content/docs/configuration/index.it.md @@ -185,6 +185,7 @@ Many of the article defaults here can be overridden on a per article basis by sp | `defaultBackgroundImage` | _Not set_ | Default background image for both `background` homepage layout and `background` hero style | | `defaultFeaturedImage` | _Not set_ | Default background image for all `featured` images across articles, will be overridden by a local `featured` image. | | `defaultSocialImage` | _Not set_ | Default image for social media sharing (Open Graph and Twitter). Will be overridden by a local `feature` image if available. | +| `hotlinkFeatureImages` | `false` | Hotlink external images in article feature images and article cards. Those images will not be processed by Hugo. | | `highlightCurrentMenuArea` | _Not set_ | Marks menu entries in the main menu when selected | | `smartTOC` | _Not set_ | Activate smart Table of Contents, items in view will be highlighted. | | `smartTOCHideUnfocusedChildren` | _Not set_ | When smart Table of Contents is turned on, this will hide deeper levels of the table when they are not in focus. | diff --git a/exampleSite/content/docs/configuration/index.ja.md b/exampleSite/content/docs/configuration/index.ja.md index 9a8adc9f..1f052649 100644 --- a/exampleSite/content/docs/configuration/index.ja.md +++ b/exampleSite/content/docs/configuration/index.ja.md @@ -185,6 +185,7 @@ Blowfish は、テーマの機能を制御する多数の設定パラメータ | `defaultBackgroundImage` | _未設定_ | `background` ホームページレイアウトと `background` ヒーロースタイルの両方のデフォルトの背景画像です。 | | `defaultFeaturedImage` | _未設定_ | 記事全体のすべての `featured` 画像のデフォルトの背景画像です。ローカルの `featured` 画像によってオーバーライドされます。 | | `defaultSocialImage` | _未設定_ | ソーシャルメディア共有(Open Graph と Twitter)用のデフォルト画像。ローカルの `featured` 画像によってオーバーライドされます。 | +| `hotlinkFeatureImages` | `false` | 記事のアイキャッチ画像や記事カードで外部画像をホットリンクします。これらの画像は Hugo によって処理されません。 | | `highlightCurrentMenuArea` | _未設定_ | メインメニューのメニュー項目が選択されているときにマークを付けます。 | | `smartTOC` | _未設定_ | スマート目次をアクティブにします。表示されている項目が強調表示されます。 | | `smartTOCHideUnfocusedChildren` | _未設定_ | スマート目次がオンになっている場合、フォーカスされていないときに、テーブルのより深いレベルが非表示になります。 | diff --git a/exampleSite/content/docs/configuration/index.md b/exampleSite/content/docs/configuration/index.md index 092526a0..cd39d4a1 100644 --- a/exampleSite/content/docs/configuration/index.md +++ b/exampleSite/content/docs/configuration/index.md @@ -191,6 +191,7 @@ Many of the article defaults here can be overridden on a per article basis by sp | `defaultBackgroundImage` | _Not set_ | Default background image for both `background` homepage layout and `background` hero style | | `defaultFeaturedImage` | _Not set_ | Default background image for all `featured` images across articles, will be overridden by a local `featured` image. | | `defaultSocialImage` | _Not set_ | Default image for social media sharing (Open Graph and Twitter). Will be overridden by a local `feature` image. | +| `hotlinkFeatureImages` | `false` | Hotlink external images in article feature images and article cards. Those images will not be processed by Hugo. | | `highlightCurrentMenuArea` | _Not set_ | Marks menu entries in the main menu when selected | | `smartTOC` | _Not set_ | Activate smart Table of Contents, items in view will be highlighted. | | `smartTOCHideUnfocusedChildren` | _Not set_ | When smart Table of Contents is turned on, this will hide deeper levels of the table when they are not in focus. | diff --git a/exampleSite/content/docs/configuration/index.zh-cn.md b/exampleSite/content/docs/configuration/index.zh-cn.md index 74425b8b..740ff503 100644 --- a/exampleSite/content/docs/configuration/index.zh-cn.md +++ b/exampleSite/content/docs/configuration/index.zh-cn.md @@ -189,6 +189,7 @@ Blowfish 提供了大量控制主题功能的配置参数,下面的表格中 | `defaultBackgroundImage` | 无 | 设置默认背景图,用于 `background` 和 `hero` 布局下的主页。 | | `defaultFeaturedImage` | 无 | 设置默认背景图片,用于所有文章的`featured`图片,可以通过文章目录中的 `featured` 图片替换。 | | `defaultSocialImage` | 无 | 社交媒体分享(Open Graph 和 Twitter)使用的默认图片,可以通过文章目录中的 `featured` 图片替换。 | +| `hotlinkFeatureImages` | `false` | 在文章特色图片和文章卡片中外链图片。这些图片不会被 Hugo 处理。 | | `highlightCurrentMenuArea` | 无 | 当菜单被选择时,标记主菜单中的菜单项。 | | `smartTOC` | 无 | 开启智能目录,视图中的项目将会被高亮显示。 | | `smartTOCHideUnfocusedChildren` | 无 | 当开启智能目录,如果目录级别不再被聚焦时,将会隐藏更深层次的目录。 | diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 40965c04..49a60051 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -6,6 +6,7 @@ data-default-appearance="{{ site.Params.defaultAppearance | default `light` }}" data-auto-appearance="{{ site.Params.autoSwitchAppearance | default `true` }}"> {{- partial "head.html" . -}} + {{- partialCached "init.html" . -}} Date: Thu, 18 Sep 2025 05:15:54 +0800 Subject: [PATCH 03/13] feat(hero): add support for `hotlinkFeatureImages` --- layouts/partials/hero/background.html | 52 ++++++---- layouts/partials/hero/basic.html | 45 +++++---- layouts/partials/hero/big.html | 96 +++++++------------ layouts/partials/hero/thumbAndBackground.html | 85 +++++++++------- layouts/partials/init.html | 3 + 5 files changed, 144 insertions(+), 137 deletions(-) diff --git a/layouts/partials/hero/background.html b/layouts/partials/hero/background.html index 026faad6..59bebb3b 100644 --- a/layouts/partials/hero/background.html +++ b/layouts/partials/hero/background.html @@ -1,28 +1,42 @@ -{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} +{{ $disableImageOptimization := site.Store.Get "disableImageOptimization" }} {{ $featured := "" }} -{{ if .Params.featureimage }} - {{ $url := .Params.featureimage }} - {{ if or (strings.HasPrefix $url "http:") (strings.HasPrefix $url "https:") }} - {{ $featured = resources.GetRemote $url }} +{{ $featuredURL := "" }} +{{ with .Params.featureimage }} + {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} + {{ if site.Params.hotlinkFeatureImages }} + {{ $featuredURL = . }} + {{ else }} + {{ $featured = resources.GetRemote . }} + {{ end }} {{ else }} - {{ $featured = resources.Get $url }} + {{ $featured = resources.Get . }} {{ end }} {{ end }} -{{ if not $featured }} - {{ $images := $.Resources.ByType "image" }} +{{ if not (or $featured $featuredURL) }} + {{ $images := .Resources.ByType "image" }} {{ range slice "*background*" "*feature*" "*cover*" "*thumbnail*" }} {{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }} {{ end }} {{ end }} -{{ if not $featured }} - {{ with .Site.Params.defaultBackgroundImage }} - {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ $featured = resources.GetRemote . }} - {{ else }} - {{ $featured = resources.Get . }} +{{ if not (or $featured $featuredURL) }} + {{ $default := site.Store.Get "defaultBackgroundImage" }} + {{ if $default.url }} + {{ $featuredURL = $default.url }} + {{ else if $default.obj }} + {{ $featured = $default.obj }} + {{ end }} +{{ end }} + +{{/* generate image URL if not hotlink */}} +{{ if not $featuredURL }} + {{ with $featured }} + {{ $featuredURL = .RelPermalink }} + {{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }} + {{ $size := site.Store.Get "backgroundImageWidth" }} + {{ $featuredURL = (.Resize $size).RelPermalink }} {{ end }} {{ end }} {{ end }} @@ -39,18 +53,14 @@ ) }} -{{- with $featured -}} +{{- with $featuredURL -}} {{ if $shouldAddHeaderSpace | default true }}
{{ end }}
- {{ $imageURL := .RelPermalink }} - {{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }} - {{ $imageURL = (.Resize (print ($.Site.Params.backgroundImageWidth | default "1200") "x")).RelPermalink }} - {{ end }} Background Image
+ data-image-url="{{ . }}"> {{ end }} {{- end -}} diff --git a/layouts/partials/hero/basic.html b/layouts/partials/hero/basic.html index 36c6f8dc..801f2cca 100644 --- a/layouts/partials/hero/basic.html +++ b/layouts/partials/hero/basic.html @@ -1,38 +1,43 @@ -{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} +{{ $disableImageOptimization := site.Store.Get "disableImageOptimization" }} {{ $featured := "" }} {{ $featuredURL := "" }} -{{ if .Params.featureimage }} - {{ $url := .Params.featureimage }} - {{ if or (strings.HasPrefix $url "http:") (strings.HasPrefix $url "https:") }} - {{ $featured = resources.GetRemote $url }} +{{ with .Params.featureimage }} + {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} + {{ if site.Params.hotlinkFeatureImages }} + {{ $featuredURL = . }} + {{ else }} + {{ $featured = resources.GetRemote . }} + {{ end }} {{ else }} - {{ $featured = resources.Get $url }} + {{ $featured = resources.Get . }} {{ end }} {{ end }} -{{ if not $featured }} - {{ $images := $.Resources.ByType "image" }} +{{ if not (or $featured $featuredURL) }} + {{ $images := .Resources.ByType "image" }} {{ range slice "*background*" "*feature*" "*cover*" "*thumbnail*" }} {{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }} {{ end }} {{ end }} -{{ if not $featured }} - {{ with .Site.Params.defaultBackgroundImage }} - {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ $featured = resources.GetRemote . }} - {{ else }} - {{ $featured = resources.Get . }} - {{ end }} +{{ if not (or $featured $featuredURL) }} + {{ $default := site.Store.Get "defaultBackgroundImage" }} + {{ if $default.url }} + {{ $featuredURL = $default.url }} + {{ else if $default.obj }} + {{ $featured = $default.obj }} {{ end }} {{ end }} -{{ with $featured }} - {{ $featuredURL = .RelPermalink }} - {{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }} - {{ $size := (print ($.Site.Params.backgroundImageWidth | default "1200") "x") }} - {{ $featuredURL = (.Resize $size).RelPermalink }} +{{/* generate image URL if not hotlink */}} +{{ if not $featuredURL }} + {{ with $featured }} + {{ $featuredURL = .RelPermalink }} + {{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }} + {{ $size := site.Store.Get "backgroundImageWidth" }} + {{ $featuredURL = (.Resize $size).RelPermalink }} + {{ end }} {{ end }} {{ end }} diff --git a/layouts/partials/hero/big.html b/layouts/partials/hero/big.html index 2a0ad286..a867f78a 100644 --- a/layouts/partials/hero/big.html +++ b/layouts/partials/hero/big.html @@ -1,28 +1,42 @@ -{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} +{{ $disableImageOptimization := site.Store.Get "disableImageOptimization" }} {{ $featured := "" }} -{{ if .Params.featureimage }} - {{ $url := .Params.featureimage }} - {{ if or (strings.HasPrefix $url "http:") (strings.HasPrefix $url "https:") }} - {{ $featured = resources.GetRemote $url }} +{{ $featuredURL := "" }} +{{ with .Params.featureimage }} + {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} + {{ if site.Params.hotlinkFeatureImages }} + {{ $featuredURL = . }} + {{ else }} + {{ $featured = resources.GetRemote . }} + {{ end }} {{ else }} - {{ $featured = resources.Get $url }} + {{ $featured = resources.Get . }} {{ end }} {{ end }} -{{ if not $featured }} - {{ $images := $.Resources.ByType "image" }} +{{ if not (or $featured $featuredURL) }} + {{ $images := .Resources.ByType "image" }} {{ range slice "*background*" "*feature*" "*cover*" "*thumbnail*" }} {{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }} {{ end }} {{ end }} -{{ if not $featured }} - {{ with .Site.Params.defaultBackgroundImage }} - {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ $featured = resources.GetRemote . }} - {{ else }} - {{ $featured = resources.Get . }} +{{ if not (or $featured $featuredURL) }} + {{ $default := site.Store.Get "defaultBackgroundImage" }} + {{ if $default.url }} + {{ $featuredURL = $default.url }} + {{ else if $default.obj }} + {{ $featured = $default.obj }} + {{ end }} +{{ end }} + +{{/* generate image URL if not hotlink */}} +{{ if not $featuredURL }} + {{ with $featured }} + {{ $featuredURL = .RelPermalink }} + {{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }} + {{ $size := site.Store.Get "backgroundImageWidth" }} + {{ $featuredURL = (.Resize $size).RelPermalink }} {{ end }} {{ end }} {{ end }} @@ -35,49 +49,13 @@ {{- $alt := .Page.Title -}} {{- with .Page.Params.alt }}{{ $alt = . }}{{ end -}} -{{- with $featured -}} - {{ if strings.HasSuffix $featured ".svg" }} - {{ with . }} -
- {{ $alt }} - {{ if $caption }} -
- {{ $caption | markdownify }} -
- {{ end }} -
+{{ with $featuredURL }} +
+ {{ $alt }} + {{ if $caption }} +
+ {{ $caption | markdownify }} +
{{ end }} - {{ else if $disableImageOptimization }} - {{ with . }} -
- {{ $alt }} - {{ if $caption }} -
- {{ $caption | markdownify }} -
- {{ end }} -
- {{ end }} - {{ else }} - {{ with .Resize (print ($.Site.Params.backgroundImageWidth | default "1200") "x") }} -
- {{ $alt }} - {{ if $caption }} -
- {{ $caption | markdownify }} -
- {{ end }} -
- {{ end }} - {{ end }} -{{- end -}} +
+{{ end }} diff --git a/layouts/partials/hero/thumbAndBackground.html b/layouts/partials/hero/thumbAndBackground.html index e378537d..877ca934 100644 --- a/layouts/partials/hero/thumbAndBackground.html +++ b/layouts/partials/hero/thumbAndBackground.html @@ -1,64 +1,75 @@ -{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} +{{ $disableImageOptimization := site.Store.Get "disableImageOptimization" }} +{{/* === Background === */}} {{ $images := .Resources.ByType "image" }} {{ $background := $images.GetMatch "*background*" }} {{ $backgroundURL := "" }} -{{ if not $background }} - {{ with .Site.Params.defaultBackgroundImage }} - {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ $background = resources.GetRemote . }} - {{ else }} - {{ $background = resources.Get . }} +{{ if not (or $background $backgroundURL) }} + {{ $default := site.Store.Get "defaultBackgroundImage" }} + {{ if $default.url }} + {{ $backgroundURL = $default.url }} + {{ else if $default.obj }} + {{ $background = $default.obj }} + {{ end }} +{{ end }} + +{{ if not (or $background $backgroundURL) }} + {{ range slice "*cover*" "*thumbnail*" "*feature*" }} + {{ if not $background }}{{ $background = $images.GetMatch . }}{{ end }} + {{ end }} +{{ end }} + +{{/* generate image URL if not hotlink */}} +{{ if not $backgroundURL }} + {{ with $background }} + {{ $backgroundURL = .RelPermalink }} + {{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }} + {{ $size := site.Store.Get "backgroundImageWidth" }} + {{ $backgroundURL = (.Resize $size).RelPermalink }} {{ end }} {{ end }} {{ end }} -{{ range slice "*cover*" "*thumbnail*" "*feature*" }} - {{ if not $background }}{{ $background = $images.GetMatch . }}{{ end }} -{{ end }} - -{{ with $background }} - {{ $backgroundURL = .RelPermalink }} - {{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }} - {{ $size := (print ($.Site.Params.backgroundImageWidth | default "1200") "x") }} - {{ $backgroundURL = (.Resize $size).RelPermalink }} - {{ end }} -{{ end }} - +{{/* === Featured === */}} {{ $featured := "" }} {{ $featuredURL := "" }} -{{ if .Params.featureimage }} - {{ $url := .Params.featureimage }} - {{ if or (strings.HasPrefix $url "http:") (strings.HasPrefix $url "https:") }} - {{ $featured = resources.GetRemote $url }} +{{ with .Params.featureimage }} + {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} + {{ if site.Params.hotlinkFeatureImages }} + {{ $featuredURL = . }} + {{ else }} + {{ $featured = resources.GetRemote . }} + {{ end }} {{ else }} - {{ $featured = resources.Get $url }} + {{ $featured = resources.Get . }} {{ end }} {{ end }} -{{ if not $featured }} +{{ if not (or $featured $featuredURL) }} {{ $images := $.Resources.ByType "image" }} {{ range slice "*feature*" "*cover*" "*thumbnail*" "*background*" }} {{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }} {{ end }} {{ end }} -{{ if not $featured }} - {{ with .Site.Params.defaultFeaturedImage }} - {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ $featured = resources.GetRemote . }} - {{ else }} - {{ $featured = resources.Get . }} - {{ end }} +{{ if not (or $featured $featuredURL) }} + {{ $default := site.Store.Get "defaultFeaturedImage" }} + {{ if $default.url }} + {{ $featuredURL = $default.url }} + {{ else if $default.obj }} + {{ $featured = $default.obj }} {{ end }} {{ end }} -{{ with $featured }} - {{ $featuredURL = .RelPermalink }} - {{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }} - {{ $size := (print ($.Site.Params.backgroundImageWidth | default "1200") "x") }} - {{ $featuredURL = (.Resize $size).RelPermalink }} +{{/* generate image URL if not hotlink */}} +{{ if not $featuredURL }} + {{ with $featured }} + {{ $featuredURL = .RelPermalink }} + {{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }} + {{ $size := site.Store.Get "backgroundImageWidth" }} + {{ $featuredURL = (.Resize $size).RelPermalink }} + {{ end }} {{ end }} {{ end }} diff --git a/layouts/partials/init.html b/layouts/partials/init.html index 6c03fa96..dd83e4e7 100644 --- a/layouts/partials/init.html +++ b/layouts/partials/init.html @@ -32,3 +32,6 @@ {{ end }} {{ end }} {{ site.Store.Set "defaultBackgroundImage" (dict "url" $defaultBackgroundImageURL "obj" $defaultBackgroundImage) }} + +{{/* backgroundImageWidth */}} +{{ site.Store.Set "backgroundImageWidth" (print (site.Params.backgroundImageWidth | default "1200") "x") }} From 9eebb5b2aa309e5e704d7f72be7ba26c349a6c39 Mon Sep 17 00:00:00 2001 From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com> Date: Thu, 18 Sep 2025 13:42:22 +0800 Subject: [PATCH 04/13] fix: img attribute add loading/decoding/fetchpriority remove alt for decorative images --- layouts/partials/article-link/_shortcode.html | 2 +- layouts/partials/article-link/card-related.html | 2 +- layouts/partials/article-link/card.html | 3 +-- layouts/partials/article-link/simple.html | 2 +- layouts/partials/hero/background.html | 5 ++++- layouts/partials/hero/basic.html | 2 +- layouts/partials/hero/big.html | 8 +++++++- layouts/partials/hero/thumbAndBackground.html | 7 +++++-- 8 files changed, 21 insertions(+), 10 deletions(-) diff --git a/layouts/partials/article-link/_shortcode.html b/layouts/partials/article-link/_shortcode.html index fe447927..11945c2b 100644 --- a/layouts/partials/article-link/_shortcode.html +++ b/layouts/partials/article-link/_shortcode.html @@ -85,7 +85,7 @@
{{ $.Title }} diff --git a/layouts/partials/article-link/card-related.html b/layouts/partials/article-link/card-related.html index c76d211d..7dbf4749 100644 --- a/layouts/partials/article-link/card-related.html +++ b/layouts/partials/article-link/card-related.html @@ -56,7 +56,7 @@ {{ end }} diff --git a/layouts/partials/article-link/simple.html b/layouts/partials/article-link/simple.html index 6a0b7009..34dfccd8 100644 --- a/layouts/partials/article-link/simple.html +++ b/layouts/partials/article-link/simple.html @@ -78,7 +78,7 @@
{{ $.Title }} diff --git a/layouts/partials/hero/background.html b/layouts/partials/hero/background.html index 59bebb3b..ac4b202c 100644 --- a/layouts/partials/hero/background.html +++ b/layouts/partials/hero/background.html @@ -61,7 +61,10 @@ Background Image
diff --git a/layouts/partials/hero/basic.html b/layouts/partials/hero/basic.html index 801f2cca..1d1c2da9 100644 --- a/layouts/partials/hero/basic.html +++ b/layouts/partials/hero/basic.html @@ -45,7 +45,7 @@
{{ $.Title }} - {{ $alt }} + {{ $alt }} {{ if $caption }}
{{ $caption | markdownify }} diff --git a/layouts/partials/hero/thumbAndBackground.html b/layouts/partials/hero/thumbAndBackground.html index 877ca934..df0ec983 100644 --- a/layouts/partials/hero/thumbAndBackground.html +++ b/layouts/partials/hero/thumbAndBackground.html @@ -84,7 +84,7 @@
{{ $.Title }} {{ end }}
Date: Sat, 27 Sep 2025 09:12:58 +0800 Subject: [PATCH 05/13] chore: hotlinkFeatureImages -> hotlinkFeatureImage --- config/_default/params.toml | 4 ++-- exampleSite/config/_default/params.toml | 10 +++++----- exampleSite/content/docs/configuration/index.it.md | 2 +- exampleSite/content/docs/configuration/index.ja.md | 2 +- exampleSite/content/docs/configuration/index.md | 2 +- exampleSite/content/docs/configuration/index.zh-cn.md | 2 +- layouts/partials/article-link/_shortcode.html | 2 +- layouts/partials/article-link/card-related.html | 2 +- layouts/partials/article-link/card.html | 2 +- layouts/partials/article-link/simple.html | 2 +- layouts/partials/hero/background.html | 2 +- layouts/partials/hero/basic.html | 2 +- layouts/partials/hero/big.html | 2 +- layouts/partials/hero/thumbAndBackground.html | 2 +- layouts/partials/init.html | 4 ++-- 15 files changed, 21 insertions(+), 21 deletions(-) diff --git a/config/_default/params.toml b/config/_default/params.toml index c42f194a..47f17ec2 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -23,10 +23,10 @@ disableImageOptimizationMD = false disableTextInHeader = false # backgroundImageWidth = 1200 -# defaultBackgroundImage = "IMAGE.jpg" # used as default for background images +# defaultBackgroundImage = "IMAGE.jpg" # used as default for background images # defaultFeaturedImage = "IMAGE.jpg" # used as default for featured images in all articles # defaultSocialImage = "/android-chrome-512x512.png" # used as default for social media sharing (Open Graph and Twitter) -hotlinkFeatureImages = false +hotlinkFeatureImage = false # highlightCurrentMenuArea = true # smartTOC = true diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index c075927e..97de1311 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -26,7 +26,7 @@ disableTextInHeader = false defaultBackgroundImage = "/img/background.svg" defaultFeaturedImage = "/img/featured.svg" defaultSocialImage = "/img/blowfish_banner.png" -hotlinkFeatureImages = false +hotlinkFeatureImage = false highlightCurrentMenuArea = true smartTOC = true @@ -84,8 +84,8 @@ fingerprintAlgorithm = "sha512" # Valid values are "sha512" (default), "sha384", showTableOfContents = true showRelatedContent = true relatedContentLimit = 9 - showTaxonomies = true - showAuthorsBadges = true + showTaxonomies = true + showAuthorsBadges = true showWordCount = false sharingLinks = [ "linkedin", "twitter", "bluesky", "reddit", "whatsapp", "telegram", "pinterest", "facebook", "email", "line"] showZenMode = true @@ -130,7 +130,7 @@ fingerprintAlgorithm = "sha512" # Valid values are "sha512" (default), "sha384", groupByYear = false cardView = true cardViewScreenWidth = false - + [firebase] #apiKey = "AIzaSyB5tqlqDky77Vb4Tc4apiHV4hRZI18KGiY" #authDomain = "blowfish-21fff.firebaseapp.com" @@ -173,4 +173,4 @@ fingerprintAlgorithm = "sha512" # Valid values are "sha512" (default), "sha384", # userId = "" [advertisement] - # adsense = "" \ No newline at end of file + # adsense = "" diff --git a/exampleSite/content/docs/configuration/index.it.md b/exampleSite/content/docs/configuration/index.it.md index ce09b474..f0206766 100644 --- a/exampleSite/content/docs/configuration/index.it.md +++ b/exampleSite/content/docs/configuration/index.it.md @@ -185,7 +185,7 @@ Many of the article defaults here can be overridden on a per article basis by sp | `defaultBackgroundImage` | _Not set_ | Default background image for both `background` homepage layout and `background` hero style | | `defaultFeaturedImage` | _Not set_ | Default background image for all `featured` images across articles, will be overridden by a local `featured` image. | | `defaultSocialImage` | _Not set_ | Default image for social media sharing (Open Graph and Twitter). Will be overridden by a local `feature` image if available. | -| `hotlinkFeatureImages` | `false` | Hotlink external images in article feature images and article cards. Those images will not be processed by Hugo. | +| `hotlinkFeatureImage` | `false` | Hotlink external images in article feature images and article cards. Those images will not be processed by Hugo. | | `highlightCurrentMenuArea` | _Not set_ | Marks menu entries in the main menu when selected | | `smartTOC` | _Not set_ | Activate smart Table of Contents, items in view will be highlighted. | | `smartTOCHideUnfocusedChildren` | _Not set_ | When smart Table of Contents is turned on, this will hide deeper levels of the table when they are not in focus. | diff --git a/exampleSite/content/docs/configuration/index.ja.md b/exampleSite/content/docs/configuration/index.ja.md index 1f052649..9ac72c0d 100644 --- a/exampleSite/content/docs/configuration/index.ja.md +++ b/exampleSite/content/docs/configuration/index.ja.md @@ -185,7 +185,7 @@ Blowfish は、テーマの機能を制御する多数の設定パラメータ | `defaultBackgroundImage` | _未設定_ | `background` ホームページレイアウトと `background` ヒーロースタイルの両方のデフォルトの背景画像です。 | | `defaultFeaturedImage` | _未設定_ | 記事全体のすべての `featured` 画像のデフォルトの背景画像です。ローカルの `featured` 画像によってオーバーライドされます。 | | `defaultSocialImage` | _未設定_ | ソーシャルメディア共有(Open Graph と Twitter)用のデフォルト画像。ローカルの `featured` 画像によってオーバーライドされます。 | -| `hotlinkFeatureImages` | `false` | 記事のアイキャッチ画像や記事カードで外部画像をホットリンクします。これらの画像は Hugo によって処理されません。 | +| `hotlinkFeatureImage` | `false` | 記事のアイキャッチ画像や記事カードで外部画像をホットリンクします。これらの画像は Hugo によって処理されません。 | | `highlightCurrentMenuArea` | _未設定_ | メインメニューのメニュー項目が選択されているときにマークを付けます。 | | `smartTOC` | _未設定_ | スマート目次をアクティブにします。表示されている項目が強調表示されます。 | | `smartTOCHideUnfocusedChildren` | _未設定_ | スマート目次がオンになっている場合、フォーカスされていないときに、テーブルのより深いレベルが非表示になります。 | diff --git a/exampleSite/content/docs/configuration/index.md b/exampleSite/content/docs/configuration/index.md index cd39d4a1..8b0bd819 100644 --- a/exampleSite/content/docs/configuration/index.md +++ b/exampleSite/content/docs/configuration/index.md @@ -191,7 +191,7 @@ Many of the article defaults here can be overridden on a per article basis by sp | `defaultBackgroundImage` | _Not set_ | Default background image for both `background` homepage layout and `background` hero style | | `defaultFeaturedImage` | _Not set_ | Default background image for all `featured` images across articles, will be overridden by a local `featured` image. | | `defaultSocialImage` | _Not set_ | Default image for social media sharing (Open Graph and Twitter). Will be overridden by a local `feature` image. | -| `hotlinkFeatureImages` | `false` | Hotlink external images in article feature images and article cards. Those images will not be processed by Hugo. | +| `hotlinkFeatureImage` | `false` | Hotlink external images in article feature images and article cards. Those images will not be processed by Hugo. | | `highlightCurrentMenuArea` | _Not set_ | Marks menu entries in the main menu when selected | | `smartTOC` | _Not set_ | Activate smart Table of Contents, items in view will be highlighted. | | `smartTOCHideUnfocusedChildren` | _Not set_ | When smart Table of Contents is turned on, this will hide deeper levels of the table when they are not in focus. | diff --git a/exampleSite/content/docs/configuration/index.zh-cn.md b/exampleSite/content/docs/configuration/index.zh-cn.md index 740ff503..f87ef815 100644 --- a/exampleSite/content/docs/configuration/index.zh-cn.md +++ b/exampleSite/content/docs/configuration/index.zh-cn.md @@ -189,7 +189,7 @@ Blowfish 提供了大量控制主题功能的配置参数,下面的表格中 | `defaultBackgroundImage` | 无 | 设置默认背景图,用于 `background` 和 `hero` 布局下的主页。 | | `defaultFeaturedImage` | 无 | 设置默认背景图片,用于所有文章的`featured`图片,可以通过文章目录中的 `featured` 图片替换。 | | `defaultSocialImage` | 无 | 社交媒体分享(Open Graph 和 Twitter)使用的默认图片,可以通过文章目录中的 `featured` 图片替换。 | -| `hotlinkFeatureImages` | `false` | 在文章特色图片和文章卡片中外链图片。这些图片不会被 Hugo 处理。 | +| `hotlinkFeatureImage` | `false` | 在文章特色图片和文章卡片中外链图片。这些图片不会被 Hugo 处理。 | | `highlightCurrentMenuArea` | 无 | 当菜单被选择时,标记主菜单中的菜单项。 | | `smartTOC` | 无 | 开启智能目录,视图中的项目将会被高亮显示。 | | `smartTOCHideUnfocusedChildren` | 无 | 当开启智能目录,如果目录级别不再被聚焦时,将会隐藏更深层次的目录。 | diff --git a/layouts/partials/article-link/_shortcode.html b/layouts/partials/article-link/_shortcode.html index 11945c2b..42baaa55 100644 --- a/layouts/partials/article-link/_shortcode.html +++ b/layouts/partials/article-link/_shortcode.html @@ -39,7 +39,7 @@ {{ with $page }} {{ with .Params.featureimage }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ if site.Params.hotlinkFeatureImages }} + {{ if site.Params.hotlinkFeatureImage }} {{ $featuredURL = . }} {{ else }} {{ $featured = resources.GetRemote . }} diff --git a/layouts/partials/article-link/card-related.html b/layouts/partials/article-link/card-related.html index 7dbf4749..5ca00aba 100644 --- a/layouts/partials/article-link/card-related.html +++ b/layouts/partials/article-link/card-related.html @@ -10,7 +10,7 @@ {{ with $page }} {{ with .Params.featureimage }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ if site.Params.hotlinkFeatureImages }} + {{ if site.Params.hotlinkFeatureImage }} {{ $featuredURL = . }} {{ else }} {{ $featured = resources.GetRemote . }} diff --git a/layouts/partials/article-link/card.html b/layouts/partials/article-link/card.html index 18171f8f..02dce92f 100644 --- a/layouts/partials/article-link/card.html +++ b/layouts/partials/article-link/card.html @@ -13,7 +13,7 @@ {{ with $page }} {{ with .Params.featureimage }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ if site.Params.hotlinkFeatureImages }} + {{ if site.Params.hotlinkFeatureImage }} {{ $featuredURL = . }} {{ else }} {{ $featured = resources.GetRemote . }} diff --git a/layouts/partials/article-link/simple.html b/layouts/partials/article-link/simple.html index 34dfccd8..72bf0772 100644 --- a/layouts/partials/article-link/simple.html +++ b/layouts/partials/article-link/simple.html @@ -32,7 +32,7 @@ {{ with $page }} {{ with .Params.featureimage }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ if site.Params.hotlinkFeatureImages }} + {{ if site.Params.hotlinkFeatureImage }} {{ $featuredURL = . }} {{ else }} {{ $featured = resources.GetRemote . }} diff --git a/layouts/partials/hero/background.html b/layouts/partials/hero/background.html index ac4b202c..be9d8b78 100644 --- a/layouts/partials/hero/background.html +++ b/layouts/partials/hero/background.html @@ -4,7 +4,7 @@ {{ $featuredURL := "" }} {{ with .Params.featureimage }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ if site.Params.hotlinkFeatureImages }} + {{ if site.Params.hotlinkFeatureImage }} {{ $featuredURL = . }} {{ else }} {{ $featured = resources.GetRemote . }} diff --git a/layouts/partials/hero/basic.html b/layouts/partials/hero/basic.html index 1d1c2da9..76d441c6 100644 --- a/layouts/partials/hero/basic.html +++ b/layouts/partials/hero/basic.html @@ -4,7 +4,7 @@ {{ $featuredURL := "" }} {{ with .Params.featureimage }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ if site.Params.hotlinkFeatureImages }} + {{ if site.Params.hotlinkFeatureImage }} {{ $featuredURL = . }} {{ else }} {{ $featured = resources.GetRemote . }} diff --git a/layouts/partials/hero/big.html b/layouts/partials/hero/big.html index afd895a0..21179cfe 100644 --- a/layouts/partials/hero/big.html +++ b/layouts/partials/hero/big.html @@ -4,7 +4,7 @@ {{ $featuredURL := "" }} {{ with .Params.featureimage }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ if site.Params.hotlinkFeatureImages }} + {{ if site.Params.hotlinkFeatureImage }} {{ $featuredURL = . }} {{ else }} {{ $featured = resources.GetRemote . }} diff --git a/layouts/partials/hero/thumbAndBackground.html b/layouts/partials/hero/thumbAndBackground.html index df0ec983..6d80ef01 100644 --- a/layouts/partials/hero/thumbAndBackground.html +++ b/layouts/partials/hero/thumbAndBackground.html @@ -36,7 +36,7 @@ {{ $featuredURL := "" }} {{ with .Params.featureimage }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ if site.Params.hotlinkFeatureImages }} + {{ if site.Params.hotlinkFeatureImage }} {{ $featuredURL = . }} {{ else }} {{ $featured = resources.GetRemote . }} diff --git a/layouts/partials/init.html b/layouts/partials/init.html index dd83e4e7..a65eb9a2 100644 --- a/layouts/partials/init.html +++ b/layouts/partials/init.html @@ -6,7 +6,7 @@ {{ $defaultFeaturedImageURL := "" }} {{ with site.Params.defaultFeaturedImage }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ if site.Params.hotlinkFeatureImages }} + {{ if site.Params.hotlinkFeatureImage }} {{ $defaultFeaturedImageURL = . }} {{ else }} {{ $defaultFeaturedImage = resources.GetRemote . }} @@ -22,7 +22,7 @@ {{ $defaultBackgroundImageURL := "" }} {{ with site.Params.defaultBackgroundImage }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ if site.Params.hotlinkFeatureImages }} + {{ if site.Params.hotlinkFeatureImage }} {{ $defaultBackgroundImageURL = . }} {{ else }} {{ $defaultBackgroundImage = resources.GetRemote . }} From 2e4e97c5b813d12aa4aa7f373fedaeb2bb81c275 Mon Sep 17 00:00:00 2001 From: "Nuno C." Date: Tue, 14 Oct 2025 09:48:02 +0100 Subject: [PATCH 06/13] Update layouts/partials/hero/thumbAndBackground.html Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- layouts/partials/hero/thumbAndBackground.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/hero/thumbAndBackground.html b/layouts/partials/hero/thumbAndBackground.html index 6d80ef01..25fa16af 100644 --- a/layouts/partials/hero/thumbAndBackground.html +++ b/layouts/partials/hero/thumbAndBackground.html @@ -84,7 +84,7 @@
Date: Tue, 14 Oct 2025 09:48:32 +0100 Subject: [PATCH 07/13] Update layouts/partials/hero/thumbAndBackground.html Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- layouts/partials/hero/thumbAndBackground.html | 1 + 1 file changed, 1 insertion(+) diff --git a/layouts/partials/hero/thumbAndBackground.html b/layouts/partials/hero/thumbAndBackground.html index 25fa16af..0bcaf2fd 100644 --- a/layouts/partials/hero/thumbAndBackground.html +++ b/layouts/partials/hero/thumbAndBackground.html @@ -99,6 +99,7 @@ id="background-image-main" src="{{ . }}" alt="" + role="presentation" loading="eager" decoding="async" fetchpriority="high" From f1532508870db4ef2bc2ea080bcc04d066ddd8d9 Mon Sep 17 00:00:00 2001 From: "Nuno C." Date: Tue, 14 Oct 2025 09:48:58 +0100 Subject: [PATCH 08/13] Update layouts/partials/hero/basic.html Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- layouts/partials/hero/basic.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/hero/basic.html b/layouts/partials/hero/basic.html index 76d441c6..53127cdf 100644 --- a/layouts/partials/hero/basic.html +++ b/layouts/partials/hero/basic.html @@ -45,7 +45,7 @@
Date: Tue, 14 Oct 2025 09:49:15 +0100 Subject: [PATCH 09/13] Update layouts/partials/hero/background.html Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- layouts/partials/hero/background.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/hero/background.html b/layouts/partials/hero/background.html index be9d8b78..2022365a 100644 --- a/layouts/partials/hero/background.html +++ b/layouts/partials/hero/background.html @@ -61,7 +61,7 @@ Date: Tue, 14 Oct 2025 09:49:29 +0100 Subject: [PATCH 10/13] Update layouts/partials/article-link/simple.html Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- layouts/partials/article-link/simple.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/article-link/simple.html b/layouts/partials/article-link/simple.html index 72bf0772..5912c82e 100644 --- a/layouts/partials/article-link/simple.html +++ b/layouts/partials/article-link/simple.html @@ -78,7 +78,7 @@
From fba28d5274d624b7fe1708266669c1d32ce762d7 Mon Sep 17 00:00:00 2001 From: "Nuno C." Date: Tue, 14 Oct 2025 09:49:38 +0100 Subject: [PATCH 11/13] Update layouts/partials/article-link/card.html Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- layouts/partials/article-link/card.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/article-link/card.html b/layouts/partials/article-link/card.html index 02dce92f..dc3b41c3 100644 --- a/layouts/partials/article-link/card.html +++ b/layouts/partials/article-link/card.html @@ -60,7 +60,7 @@
From cac66e0fd78aa0acefb48bbe6f2b72543293334f Mon Sep 17 00:00:00 2001 From: "Nuno C." Date: Tue, 14 Oct 2025 09:49:50 +0100 Subject: [PATCH 12/13] Update layouts/partials/article-link/card-related.html Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- layouts/partials/article-link/card-related.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/article-link/card-related.html b/layouts/partials/article-link/card-related.html index 5ca00aba..4612ad2a 100644 --- a/layouts/partials/article-link/card-related.html +++ b/layouts/partials/article-link/card-related.html @@ -56,7 +56,7 @@