Skip to content

Commit

Permalink
fix: append hash into the JavaScript variables file
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Oct 15, 2024
1 parent 10a20a8 commit 8a4c3cb
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions layouts/partials/echarts/assets/script.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
<script src="{{ $js.RelPermalink }}"></script>
{{- end }}
{{- with .Store.Get "eChartsJSVars" }}
{{- $hash := jsonify . | md5 }}
{{- $jsVars := resources.Get "mods/echarts/js-vars.js" }}
{{- $jsVarsPath := printf "%s/echarts-vars.js" page.RelPermalink }}
{{- $jsVarsPath := printf "%s/echarts-vars.%s.js" page.RelPermalink $hash }}
{{- $jsVars = $jsVars
| resources.ExecuteAsTemplate $jsVarsPath .
| js.Build (dict "targetPath" $jsVarsPath "minify" hugo.IsProduction)
}}
{{- if hugo.IsProduction }}
{{- $jsVars = $jsVars | fingerprint }}
{{- end }}
<script src="{{ $jsVars.RelPermalink }}"></script>
{{- end }}

0 comments on commit 8a4c3cb

Please sign in to comment.