🎨 Optimize resource fingerprint replace with unixtime for CDN.

This commit is contained in:
elkan1788
2024-11-24 16:33:35 +08:00
parent fdfcadadcc
commit ee4a22d88a
4 changed files with 20 additions and 13 deletions

View File

@@ -0,0 +1,4 @@
{{/** Add unix time end of link URL. **/}}
{{ $timeUnix := time.Now.Unix }}
{{ $withTimeLink := printf "%s?=%d" . $timeUnix }}
{{ return $withTimeLink }}

View File

@@ -5,7 +5,7 @@
{{ $plugin := resources.Get $pluginPath | resources.ExecuteAsTemplate $targetPath .ctx }}
{{ if hugo.IsProduction }}
{{ $plugin = $plugin | minify | fingerprint }}
{{ $plugin = $plugin | minify }}
{{ end }}
<script type="text/javascript" src="{{ $plugin.RelPermalink }}" defer></script>
{{ $unixSrc := partial "_funs/add_unix_param.html" $plugin.RelPermalink }}
<script type="text/javascript" src="{{ $unixSrc }}" defer></script>