diff --git a/layouts/_partials/assets.html b/layouts/_partials/assets.html index 4ccc36ab..4f0bde2f 100644 --- a/layouts/_partials/assets.html +++ b/layouts/_partials/assets.html @@ -19,9 +19,9 @@ FixIt theme assets partial {{- $config := (.Store.Get "this").config -}} {{- $config = dict "version" (hugo.Store.Get "version") | merge $config -}} {{- $author := partial "function/get-author-map.html" .Params.author -}} -{{- $noBaseRelPermalink := strings.TrimPrefix (relURL "") $.RelPermalink -}} +{{- $uniqueFileId := "" -}} {{- with .File -}} - {{- $noBaseRelPermalink = replace $noBaseRelPermalink (.BaseFileName | urlize) .BaseFileName -}} + {{- $uniqueFileId = .UniqueID -}} {{- end -}} {{- /* Search */ -}} @@ -326,17 +326,17 @@ FixIt theme assets partial {{- if hugo.IsServer -}} {{- $configJS = add $configJS "console.log('Page config:', window.config);" -}} {{- end -}} -{{- $targetPath := $noBaseRelPermalink | printf "%s/config/page.js" -}} -{{- if (path.Ext .Page.RelPermalink) | or .IsHome -}} - {{- $targetPath = "" -}} +{{- $targetPath := "" -}} +{{- if $uniqueFileId -}} + {{- $targetPath = $uniqueFileId | printf "js/config/%s.js" -}} {{- end -}} {{- dict "Content" $configJS "Path" $targetPath "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} {{- /* MathJax plugin */ -}} {{- if .Store.Get "hasMathJax" -}} - {{- $targetPath := $noBaseRelPermalink | printf "%s/mathjax.min.js" -}} - {{- if (path.Ext .Page.RelPermalink) | or .IsHome -}} - {{- $targetPath = "" -}} + {{- $targetPath := "" -}} + {{- if $uniqueFileId -}} + {{- $targetPath = $uniqueFileId | printf "js/lib/mathjax/%s.min.js" -}} {{- end -}} {{- $options := dict "targetPath" $targetPath "minify" hugo.IsProduction -}} {{- if not hugo.IsProduction -}} @@ -373,14 +373,14 @@ FixIt theme assets partial {{- with .Store.Get "styleArr" -}} {{- $content := delimit . " " -}} - {{- $path := $noBaseRelPermalink | printf "%s/index.scss" -}} - {{- $options := printf "%s/index.min.css" $noBaseRelPermalink | dict "targetPath" -}} + {{- $path := $uniqueFileId | printf "css/page/%s.scss" -}} + {{- $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 := $noBaseRelPermalink | printf "%s/index.js" -}} + {{- $targetPath := $uniqueFileId | printf "js/page/%s.js" -}} {{- dict "Content" $content "Path" $targetPath "Defer" true | dict "Page" $ "Data" | partial "store/script.html" -}} {{- end -}} diff --git a/layouts/_partials/plugin/post-chat-ai.html b/layouts/_partials/plugin/post-chat-ai.html index 66441995..057cec4c 100644 --- a/layouts/_partials/plugin/post-chat-ai.html +++ b/layouts/_partials/plugin/post-chat-ai.html @@ -100,9 +100,13 @@ {{- end -}} {{- /* Insert config */ -}} - {{- $targetPath := (strings.TrimPrefix (relURL "") $.RelPermalink) | printf "%s/config/post-chat.js" -}} - {{- if (path.Ext .Page.RelPermalink) | or .IsHome -}} - {{- $targetPath = "" -}} + {{- $uniqueFileId := "" -}} + {{- with .File -}} + {{- $uniqueFileId = .UniqueID -}} + {{- end -}} + {{- $targetPath := "" -}} + {{- if $uniqueFileId -}} + {{- $targetPath = $uniqueFileId | printf "js/config/post-chat/%s.js" -}} {{- end -}} {{- dict "Content" $configJS "Path" $targetPath "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}}