mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
fix: update asset paths to use unique file IDs for better resource management (#658)
This commit is contained in:
@@ -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 -}}
|
||||
|
||||
|
||||
@@ -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" -}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user