From edd709809ea68ebbf699de9695c7d789549d953c Mon Sep 17 00:00:00 2001 From: PCloud Date: Fri, 17 Jan 2025 15:30:07 +0000 Subject: [PATCH 1/6] try --- layouts/partials/function/getRemoteImage.html | 2 +- layouts/partials/plugin/image.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/partials/function/getRemoteImage.html b/layouts/partials/function/getRemoteImage.html index 9e09b28ab..b58b6d572 100644 --- a/layouts/partials/function/getRemoteImage.html +++ b/layouts/partials/function/getRemoteImage.html @@ -7,7 +7,7 @@ {{- end -}} {{- if (eq $suffixList false) | or $valid -}} - {{- with $remoteResource := resources.GetRemote . -}} + {{- with try $remoteResource := resources.GetRemote . -}} {{- with .Err -}} {{- warnf "%s" . -}} {{ else }} diff --git a/layouts/partials/plugin/image.html b/layouts/partials/plugin/image.html index 7f0ebca8f..6c7f8e2ec 100644 --- a/layouts/partials/plugin/image.html +++ b/layouts/partials/plugin/image.html @@ -39,7 +39,7 @@ {{- $optimise := .Optimise | default site.Params.image.optimise | default false -}} {{- if not $resource | and $isUrlRemote | and $cacheRemote -}} - {{- with $remoteResource := resources.GetRemote .Src -}} + {{- with try $remoteResource := resources.GetRemote .Src -}} {{- with .Err -}} {{- warnf "%s" . -}} {{ else }} From 1d1808589519143a64b948dfbaf58a5bf6c3b40e Mon Sep 17 00:00:00 2001 From: PCloud Date: Fri, 17 Jan 2025 15:34:27 +0000 Subject: [PATCH 2/6] try2 --- layouts/partials/function/getRemoteImage.html | 6 +++--- layouts/partials/plugin/image.html | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/layouts/partials/function/getRemoteImage.html b/layouts/partials/function/getRemoteImage.html index b58b6d572..833713a2e 100644 --- a/layouts/partials/function/getRemoteImage.html +++ b/layouts/partials/function/getRemoteImage.html @@ -7,12 +7,12 @@ {{- end -}} {{- if (eq $suffixList false) | or $valid -}} - {{- with try $remoteResource := resources.GetRemote . -}} + {{- with try resources.GetRemote . -}} {{- with .Err -}} {{- warnf "%s" . -}} {{ else }} - {{- if eq $remoteResource.ResourceType "image" -}} - {{- $resource = $remoteResource -}} + {{- if eq .Value.ResourceType "image" -}} + {{- $resource = .Value -}} {{- end -}} {{- end -}} {{- end -}} diff --git a/layouts/partials/plugin/image.html b/layouts/partials/plugin/image.html index 6c7f8e2ec..02769b1d8 100644 --- a/layouts/partials/plugin/image.html +++ b/layouts/partials/plugin/image.html @@ -39,12 +39,12 @@ {{- $optimise := .Optimise | default site.Params.image.optimise | default false -}} {{- if not $resource | and $isUrlRemote | and $cacheRemote -}} - {{- with try $remoteResource := resources.GetRemote .Src -}} + {{- with try resources.GetRemote .Src -}} {{- with .Err -}} {{- warnf "%s" . -}} {{ else }} - {{- if $remoteResource.ResourceType | eq "image" -}} - {{- $resource = $remoteResource -}} + {{- if .Value.ResourceType | eq "image" -}} + {{- $resource = .Value -}} {{- end -}} {{- end -}} {{- end -}} From 8bd00e153f96a970dd0561fb6cfa945231e978d8 Mon Sep 17 00:00:00 2001 From: PCloud Date: Fri, 17 Jan 2025 15:37:56 +0000 Subject: [PATCH 3/6] x --- .../posts/tests/builtin-shortcodes-tests/index.en.md | 4 ++-- .../index.en.md | 10 +++++----- .../index.zh-cn.md | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/exampleSite/content/posts/tests/builtin-shortcodes-tests/index.en.md b/exampleSite/content/posts/tests/builtin-shortcodes-tests/index.en.md index dafcc6795..0aa0435b5 100644 --- a/exampleSite/content/posts/tests/builtin-shortcodes-tests/index.en.md +++ b/exampleSite/content/posts/tests/builtin-shortcodes-tests/index.en.md @@ -30,9 +30,9 @@ hiddenFromSearch: true [relref]({{< relref "../../../about/index.en.md" >}}) -## tweet +## x -{{< tweet user="SanDiegoZoo" id="1453110110599868418" >}} +{{< x user="SanDiegoZoo" id="1453110110599868418" >}} ## vimeo diff --git a/exampleSite/content/posts/theme-documentation-built-in-shortcodes/index.en.md b/exampleSite/content/posts/theme-documentation-built-in-shortcodes/index.en.md index f4f6edd9d..e49985a05 100644 --- a/exampleSite/content/posts/theme-documentation-built-in-shortcodes/index.en.md +++ b/exampleSite/content/posts/theme-documentation-built-in-shortcodes/index.en.md @@ -91,17 +91,17 @@ The rendered output looks like this: [Documentation of `ref` and `relref`](https://gohugo.io/content-management/shortcodes#ref-and-relref) -## tweet +## x -[Documentation of `tweet`](https://gohugo.io/content-management/shortcodes#tweet) +[Documentation of `x`](https://gohugo.io/content-management/shortcodes#x) -Example `tweet` input: +Example `x` input: ```markdown -{{}} +{{}} ``` -{{< tweet user="SanDiegoZoo" id="1453110110599868418" >}} +{{< x user="SanDiegoZoo" id="1453110110599868418" >}} ## vimeo diff --git a/exampleSite/content/posts/theme-documentation-built-in-shortcodes/index.zh-cn.md b/exampleSite/content/posts/theme-documentation-built-in-shortcodes/index.zh-cn.md index b4a3a982f..46d5d9738 100644 --- a/exampleSite/content/posts/theme-documentation-built-in-shortcodes/index.zh-cn.md +++ b/exampleSite/content/posts/theme-documentation-built-in-shortcodes/index.zh-cn.md @@ -92,17 +92,17 @@ Hugo 附带了一组预定义的 shortcodes, 它们实现了一些非常常见 [`ref` 和 `relref` 的文档](https://gohugo.io/content-management/shortcodes#ref-and-relref) -## tweet +## x -[`tweet` 的文档](https://gohugo.io/content-management/shortcodes#tweet) +[`x` 的文档](https://gohugo.io/content-management/shortcodes#x) -一个 `tweet` 示例: +一个 `x` 示例: ```markdown -{{}} +{{}} ``` -{{< tweet user="SanDiegoZoo" id="1453110110599868418" >}} +{{< x user="SanDiegoZoo" id="1453110110599868418" >}} ## vimeo From 6d5ea0ed5c6ad94c752c01687f6a1d2afe0af968 Mon Sep 17 00:00:00 2001 From: PCloud Date: Fri, 17 Jan 2025 15:44:55 +0000 Subject: [PATCH 4/6] privacy.x --- exampleSite/config/_default/privacy.toml | 2 +- .../content/posts/theme-documentation-basics/index.en.md | 2 +- .../content/posts/theme-documentation-basics/index.zh-cn.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/exampleSite/config/_default/privacy.toml b/exampleSite/config/_default/privacy.toml index 0272ac902..a2280243e 100644 --- a/exampleSite/config/_default/privacy.toml +++ b/exampleSite/config/_default/privacy.toml @@ -5,7 +5,7 @@ # Google Analytics 相关隐私 (被 params.analytics.google 替代) [googleAnalytics] # ... -[twitter] +[x] enableDNT = true [youtube] privacyEnhanced = true diff --git a/exampleSite/content/posts/theme-documentation-basics/index.en.md b/exampleSite/content/posts/theme-documentation-basics/index.en.md index f59e31b2b..2aff7b40c 100644 --- a/exampleSite/content/posts/theme-documentation-basics/index.en.md +++ b/exampleSite/content/posts/theme-documentation-basics/index.en.md @@ -895,7 +895,7 @@ Please open the code block below to view the complete sample configuration {{< f # {{< version 0.2.0 deleted >}} privacy of the Google Analytics (replaced by params.analytics.google) [privacy.googleAnalytics] # ... - [privacy.twitter] + [privacy.x] enableDNT = true [privacy.youtube] privacyEnhanced = true diff --git a/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md b/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md index 634ca6693..bffc91bd2 100644 --- a/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md +++ b/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md @@ -897,7 +897,7 @@ optimizeImages = true # {{< version 0.2.0 deleted >}} Google Analytics 相关隐私 (被 params.analytics.google 替代) [privacy.googleAnalytics] # ... - [privacy.twitter] + [privacy.x] enableDNT = true [privacy.youtube] privacyEnhanced = true From 9bf0f021048efbe1b4cf2ef5b0e479be0c2d4b55 Mon Sep 17 00:00:00 2001 From: PCloud Date: Fri, 17 Jan 2025 15:52:20 +0000 Subject: [PATCH 5/6] raise minimal hugo version --- layouts/partials/init.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/layouts/partials/init.html b/layouts/partials/init.html index a8633b034..e469976a5 100644 --- a/layouts/partials/init.html +++ b/layouts/partials/init.html @@ -1,9 +1,9 @@ {{- .Scratch.Set "version" "0.4.0" -}} {{- /* Check Hugo version */ -}} -{{- $OLDEST_SUPPORTED_HUGO_VERSION := "0.134.0" -}} -{{- if lt hugo.Version $OLDEST_SUPPORTED_HUGO_VERSION -}} - {{- errorf "\n\nHugo version is too low.\nHugo 版本过低。\n\nCurrent Hugo version is %v, the oldest supported version is %v.\n目前使用的 Hugo 版本为 %v, DoIt 支持的最老的 Hugo 版本为 %v。\n\nIf you are running Hugo on your own computer, check out https://gohugo.io/getting-started/installing/#upgrade-hugo for upgrading guide.\n如果你正在自己的计算机上运行 Hugo,请访问 https://gohugo.io/getting-started/installing/#upgrade-hugo 以查阅升级指南。\n\nIf you are deploying on a third-party platform, please configure Hugo version accordingly.\n如果你正在第三方平台上部署,请按照相应文档配置 Hugo 版本。\n\n" hugo.Version $OLDEST_SUPPORTED_HUGO_VERSION hugo.Version $OLDEST_SUPPORTED_HUGO_VERSION -}} +{{- $MINIMAL_HUGO_VERSION := "0.141.0" -}} +{{- if lt hugo.Version $MINIMAL_HUGO_VERSION -}} + {{- errorf "\n\nHugo version is too low.\nHugo 版本过低。\n\nCurrent Hugo version is %v, the oldest supported version is %v.\n目前使用的 Hugo 版本为 %v, DoIt 支持的最老的 Hugo 版本为 %v。\n\nIf you are running Hugo on your own computer, check out https://gohugo.io/getting-started/installing/#upgrade-hugo for upgrading guide.\n如果你正在自己的计算机上运行 Hugo,请访问 https://gohugo.io/getting-started/installing/#upgrade-hugo 以查阅升级指南。\n\nIf you are deploying on a third-party platform, please configure Hugo version accordingly.\n如果你正在第三方平台上部署,请按照相应文档配置 Hugo 版本。\n\n" hugo.Version $MINIMAL_HUGO_VERSION hugo.Version $MINIMAL_HUGO_VERSION -}} {{- end -}} {{- /* Check Hugo extend */ -}} From 995f59a486f6740d8b57c40c3acdf5093e7874d5 Mon Sep 17 00:00:00 2001 From: PCloud Date: Fri, 17 Jan 2025 16:00:47 +0000 Subject: [PATCH 6/6] chore: refactor --- layouts/partials/function/getImage.html | 17 ---------------- layouts/partials/function/getRemoteImage.html | 20 ------------------- layouts/partials/plugin/image.html | 12 ++++++----- 3 files changed, 7 insertions(+), 42 deletions(-) delete mode 100644 layouts/partials/function/getImage.html delete mode 100644 layouts/partials/function/getRemoteImage.html diff --git a/layouts/partials/function/getImage.html b/layouts/partials/function/getImage.html deleted file mode 100644 index c893b6d0a..000000000 --- a/layouts/partials/function/getImage.html +++ /dev/null @@ -1,17 +0,0 @@ -{{- $path:= .Path -}} -{{- $imageResource := 0 -}} - -{{- with dict "Path" $path "Resources" .Resources | partial "function/resource.html" -}} - {{- $imageResource = . -}} -{{- else -}} - {{- $url := urls.Parse .Path -}} - {{- if (eq site.Params.cacheRemoteImages true) | and (partial "function/isUrlRemote.html" $url) | and .Remote -}} - {{- $imageResource = partial "function/getRemoteImage.html" $path -}} - {{- end -}} -{{- end -}} - -{{- if not (and (not (eq $imageResource 0)) (eq $imageResource.ResourceType "image")) -}} - {{- $imageResource = 0 -}} -{{- end -}} - -{{- return $imageResource -}} diff --git a/layouts/partials/function/getRemoteImage.html b/layouts/partials/function/getRemoteImage.html deleted file mode 100644 index 833713a2e..000000000 --- a/layouts/partials/function/getRemoteImage.html +++ /dev/null @@ -1,20 +0,0 @@ -{{- $resource := 0 -}} -{{- $suffixList := site.Params.suffixValidationList | default (slice ".jpeg" ".jpg" ".png" ".gif" ".bmp" ".tif" ".tiff" ".webp" ".avif" ".svg") -}} - -{{- $valid := false -}} -{{- if not (eq $suffixList false) -}} - {{- $valid = (dict "Path" . "Suffixes" $suffixList | partial "function/suffixValidation.html") -}} -{{- end -}} - -{{- if (eq $suffixList false) | or $valid -}} - {{- with try resources.GetRemote . -}} - {{- with .Err -}} - {{- warnf "%s" . -}} - {{ else }} - {{- if eq .Value.ResourceType "image" -}} - {{- $resource = .Value -}} - {{- end -}} - {{- end -}} - {{- end -}} -{{- end -}} -{{- return $resource -}} diff --git a/layouts/partials/plugin/image.html b/layouts/partials/plugin/image.html index 02769b1d8..0a8a5eb34 100644 --- a/layouts/partials/plugin/image.html +++ b/layouts/partials/plugin/image.html @@ -39,14 +39,16 @@ {{- $optimise := .Optimise | default site.Params.image.optimise | default false -}} {{- if not $resource | and $isUrlRemote | and $cacheRemote -}} - {{- with try resources.GetRemote .Src -}} + {{- with try (resources.GetRemote .Src) -}} {{- with .Err -}} {{- warnf "%s" . -}} - {{ else }} - {{- if .Value.ResourceType | eq "image" -}} - {{- $resource = .Value -}} + {{- else with .Value -}} + {{- if .ResourceType | eq "image" -}} + {{- $resource = . -}} {{- end -}} - {{- end -}} + {{- else -}} + {{- warnf "Unable to get resource %q" .Src -}} + {{- end -}} {{- end -}} {{- end -}}