From e482fbe36ab817267336bc7543f53c8d8c14dee4 Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Sat, 30 Dec 2023 23:59:07 +0800 Subject: [PATCH] :zap: Chore: optimize .Resources variable acquisition in function resources.html --- layouts/_default/_markup/render-image.html | 4 ++-- layouts/_default/_markup/render-link.html | 2 +- layouts/friends/single.html | 2 +- layouts/page/friends.html | 2 +- layouts/partials/function/resource.html | 5 +++-- layouts/partials/head/seo.html | 8 ++++---- layouts/partials/plugin/reward.html | 2 +- layouts/partials/rss/item.html | 2 +- layouts/posts/single.html | 2 +- layouts/shortcodes/image.html | 2 +- layouts/shortcodes/link.html | 2 +- layouts/shortcodes/music.html | 4 ++-- 12 files changed, 19 insertions(+), 18 deletions(-) diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 68cc9f92..7f9382a0 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,11 +1,11 @@ {{- if .Title | and .Text -}}
- {{- dict "Src" .Destination "Alt" .Text "Caption" .Text "Title" .Title "Linked" true "Resources" .Page.Resources "Responsive" true | partial "plugin/image.html" -}} + {{- dict "Src" .Destination "Alt" .Text "Caption" .Text "Title" .Title "Linked" true "Responsive" true | partial "plugin/image.html" -}}
{{- .Text | safeHTML -}}
{{- else -}} {{- $linked := (eq (.Page.Scratch.Get "params").lightgallery "force") | or (ne .Title "") -}} - {{- dict "Src" .Destination "Alt" .Text "Title" .Title "Linked" $linked "Resources" .Page.Resources "Responsive" true | partial "plugin/image.html" -}} + {{- dict "Src" .Destination "Alt" .Text "Title" .Title "Linked" $linked "Responsive" true | partial "plugin/image.html" -}} {{- end -}} diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index 8470fb03..26b1ea68 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -1,5 +1,5 @@ {{- $destination := .Destination -}} -{{- with dict "Path" $destination "Resources" .Page.Resources | partial "function/resource.html" -}} +{{- with dict "Path" $destination | partial "function/resource.html" -}} {{- $destination = .RelPermalink -}} {{- end -}} {{- $options := dict "Destination" $destination "Title" .Title "Content" .Text "ExternalIcon" .Page.Site.Params.externalIcon -}} diff --git a/layouts/friends/single.html b/layouts/friends/single.html index dcd80dc7..c069f7a5 100644 --- a/layouts/friends/single.html +++ b/layouts/friends/single.html @@ -22,7 +22,7 @@ {{ range $index, $friend := .Site.Data.friends }} {{ if $friend.avatar }} - {{- dict "Src" $friend.avatar "Alt" $friend.nickname "Class" "friend-avatar" "Resources" $.Resources | partial "plugin/image.html" -}} + {{- dict "Src" $friend.avatar "Alt" $friend.nickname "Class" "friend-avatar" | partial "plugin/image.html" -}} {{ else }}
- {{- dict "Src" $image "Alt" (printf "%v %v" $author $way) "Resources" $.Resources | partial "plugin/image.html" -}} + {{- dict "Src" $image "Alt" (printf "%v %v" $author $way) | partial "plugin/image.html" -}} {{ $way }}
{{- end -}} diff --git a/layouts/partials/rss/item.html b/layouts/partials/rss/item.html index b320b5cb..bc86c4ab 100644 --- a/layouts/partials/rss/item.html +++ b/layouts/partials/rss/item.html @@ -33,7 +33,7 @@ {{- " - {{- dict "Src" . "Title" $.Page.Description "Alt" $.Page.Title "Resources" $.Page.Resources "Loading" "eager" "Referrerpolicy" "no-referrer" | partial "plugin/image.html" -}} + {{- dict "Src" . "Title" $.Page.Description "Alt" $.Page.Title "Loading" "eager" "Referrerpolicy" "no-referrer" | partial "plugin/image.html" -}} {{- end -}} {{- $content := .Page.Description -}} diff --git a/layouts/posts/single.html b/layouts/posts/single.html index a2ae635a..d5b0bca6 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -142,7 +142,7 @@ {{- end -}} {{- with $image -}} {{- end -}} diff --git a/layouts/shortcodes/image.html b/layouts/shortcodes/image.html index ea2f01f0..828b9ac2 100644 --- a/layouts/shortcodes/image.html +++ b/layouts/shortcodes/image.html @@ -16,7 +16,7 @@ {{- $options = cond $caption true false | dict "Linked" | merge $options -}} {{- end -}} -{{- $options = dict "Resources" .Page.Resources "Responsive" true | merge $options -}} +{{- $options = dict "Responsive" true | merge $options -}} {{- with $caption -}} diff --git a/layouts/shortcodes/link.html b/layouts/shortcodes/link.html index bf0615e6..10c20ed9 100644 --- a/layouts/shortcodes/link.html +++ b/layouts/shortcodes/link.html @@ -1,5 +1,5 @@ {{- $destination := cond .IsNamedParams (.Get "href") (.Get 0) -}} -{{- with dict "Path" $destination "Resources" .Page.Resources | partial "function/resource.html" -}} +{{- with dict "Path" $destination | partial "function/resource.html" -}} {{- $destination = .RelPermalink -}} {{- end -}} {{- $options := dict "Destination" $destination -}} diff --git a/layouts/shortcodes/music.html b/layouts/shortcodes/music.html index 2c3ec031..53dc923b 100644 --- a/layouts/shortcodes/music.html +++ b/layouts/shortcodes/music.html @@ -3,11 +3,11 @@ {{- $theme = .Get "theme" | default $theme -}} {{- if .Get "url" -}} {{- $url := .Get "url" -}} - {{- with dict "Path" $url "Resources" .Page.Resources | partial "function/resource.html" -}} + {{- with dict "Path" $url | partial "function/resource.html" -}} {{- $url = .RelPermalink -}} {{- end -}} {{- $cover := .Get "cover" -}} - {{- with dict "Path" $cover "Resources" .Page.Resources | partial "function/resource.html" -}} + {{- with dict "Path" $cover | partial "function/resource.html" -}} {{- $cover = .RelPermalink -}} {{- end -}}