From ffe0c3bd6774c55689d7372f9065fa42f5b0c273 Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Mon, 24 Nov 2025 18:06:09 +0800 Subject: [PATCH] fix: config.js was not working on multilingual sites (#658) --- layouts/_partials/assets.html | 9 +++++---- layouts/_partials/init/index.html | 2 +- layouts/_partials/plugin/post-chat-ai.html | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/layouts/_partials/assets.html b/layouts/_partials/assets.html index 41cc213b..41ebfb38 100644 --- a/layouts/_partials/assets.html +++ b/layouts/_partials/assets.html @@ -20,6 +20,7 @@ FixIt theme assets partial {{- $config = dict "version" (hugo.Store.Get "version") | merge $config -}} {{- $author := partial "function/get-author-map.html" .Params.author -}} {{- $uniqueFileId := "" -}} +{{- $languagePrefix := .Site.LanguagePrefix -}} {{- with .File -}} {{- $uniqueFileId = .UniqueID -}} {{- end -}} @@ -328,7 +329,7 @@ FixIt theme assets partial {{- end -}} {{- $targetPath := "" -}} {{- if $uniqueFileId -}} - {{- $targetPath = $uniqueFileId | printf "js/config/%s.js" -}} + {{- $targetPath = printf "%s/js/config/%s.js" $languagePrefix $uniqueFileId -}} {{- end -}} {{- dict "Content" $configJS "Path" $targetPath "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} @@ -336,7 +337,7 @@ FixIt theme assets partial {{- if .Store.Get "hasMathJax" -}} {{- $targetPath := "" -}} {{- if $uniqueFileId -}} - {{- $targetPath = $uniqueFileId | printf "js/lib/mathjax/%s.min.js" -}} + {{- $targetPath = printf "%s/js/lib/mathjax/%s.min.js" $languagePrefix $uniqueFileId -}} {{- end -}} {{- $options := dict "targetPath" $targetPath "minify" hugo.IsProduction -}} {{- if not hugo.IsProduction -}} @@ -373,14 +374,14 @@ FixIt theme assets partial {{- with .Store.Get "styleArr" -}} {{- $content := delimit . " " -}} - {{- $path := $uniqueFileId | printf "css/page/%s.scss" -}} + {{- $path := printf "%s/css/page/%s.scss" $languagePrefix $uniqueFileId -}} {{- $options := printf "css/page/%s.min.css" $uniqueFileId | dict "targetPath" -}} {{- dict "Content" $content "Path" $path "ToCSS" $options | dict "Page" $ "Data" | partial "store/style.html" -}} {{- end -}} {{- with .Store.Get "scriptArr" -}} {{- $content := delimit . "\n" -}} - {{- $targetPath := $uniqueFileId | printf "js/page/%s.js" -}} + {{- $targetPath := printf "%s/js/page/%s.js" $languagePrefix $uniqueFileId -}} {{- dict "Content" $content "Path" $targetPath "Defer" true | dict "Page" $ "Data" | partial "store/script.html" -}} {{- end -}} diff --git a/layouts/_partials/init/index.html b/layouts/_partials/init/index.html index c94a90e1..3c31328d 100644 --- a/layouts/_partials/init/index.html +++ b/layouts/_partials/init/index.html @@ -1,4 +1,4 @@ -{{- hugo.Store.Set "version" "v0.4.0-alpha.3-20251124094436-9c98f214" -}} +{{- hugo.Store.Set "version" "v0.4.0-alpha.3-20251124100610-99fd4fb7" -}} {{- .Store.Set "this" dict -}} {{- partial "init/detection-env.html" . -}} diff --git a/layouts/_partials/plugin/post-chat-ai.html b/layouts/_partials/plugin/post-chat-ai.html index 057cec4c..cec6449d 100644 --- a/layouts/_partials/plugin/post-chat-ai.html +++ b/layouts/_partials/plugin/post-chat-ai.html @@ -101,12 +101,13 @@ {{- /* Insert config */ -}} {{- $uniqueFileId := "" -}} + {{- $languagePrefix := .Site.LanguagePrefix -}} {{- with .File -}} {{- $uniqueFileId = .UniqueID -}} {{- end -}} {{- $targetPath := "" -}} {{- if $uniqueFileId -}} - {{- $targetPath = $uniqueFileId | printf "js/config/post-chat/%s.js" -}} + {{- $targetPath = printf "%s/js/config/post-chat/%s.js" $languagePrefix $uniqueFileId -}} {{- end -}} {{- dict "Content" $configJS "Path" $targetPath "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}}