🎨 Optimize resource fingerprint replace with unixtime for CDN.
This commit is contained in:
parent
fdfcadadcc
commit
ee4a22d88a
4
layouts/partials/_funs/add_unix_param.html
Normal file
4
layouts/partials/_funs/add_unix_param.html
Normal file
@ -0,0 +1,4 @@
|
||||
{{/** Add unix time end of link URL. **/}}
|
||||
{{ $timeUnix := time.Now.Unix }}
|
||||
{{ $withTimeLink := printf "%s?=%d" . $timeUnix }}
|
||||
{{ return $withTimeLink }}
|
@ -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>
|
@ -13,19 +13,21 @@
|
||||
{{ $scss = $scss | resources.ExecuteAsTemplate "main.scss" . }}
|
||||
{{ $css := $scss | toCSS (dict "targetPath" "/css/main.css" "outputStyle" "expanded") }}
|
||||
{{ if hugo.IsProduction }}
|
||||
{{ $css = $css | minify | fingerprint }}
|
||||
{{ $css = $css | minify }}
|
||||
{{ end }}
|
||||
<link rel="stylesheet" href="{{ $css.RelPermalink }}">
|
||||
{{ $unixHref := partial "_funs/add_unix_param.html" $css.RelPermalink }}
|
||||
<link rel="stylesheet" href="{{ $unixHref }}">
|
||||
{{ if .IsPage }}
|
||||
<style type="text/css">
|
||||
.post-footer, .flinks-list-footer hr:after {
|
||||
content: "{{ .Site.Params.postFooter.endLineTip }}";
|
||||
}
|
||||
</style>
|
||||
<style type="text/css">
|
||||
.post-footer, .flinks-list-footer hr:after {
|
||||
content: "{{ .Site.Params.postFooter.endLineTip }}";
|
||||
}
|
||||
</style>
|
||||
{{ end }}
|
||||
|
||||
{{ $custom := .Scratch.Get "style" }}
|
||||
{{ if $custom }}
|
||||
<link rel="stylesheet" type="text/css" href="{{ $custom }}">
|
||||
{{ $unixHref := partial "_funs/add_unix_param.html" $custom }}
|
||||
<link rel="stylesheet" type="text/css" href="{{ $unixHref }}">
|
||||
{{ end }}
|
||||
|
@ -113,6 +113,7 @@
|
||||
|
||||
{{ $nextjs = $nextjs | resources.Concat "js/main.js"}}
|
||||
{{ if hugo.IsProduction }}
|
||||
{{ $nextjs = $nextjs | minify | fingerprint }}
|
||||
{{ $nextjs = $nextjs | minify }}
|
||||
{{ end }}
|
||||
<script type="text/javascript" src="{{ $nextjs.RelPermalink }}" defer></script>
|
||||
{{ $unixSrc := partial "_funs/add_unix_param.html" $nextjs.RelPermalink }}
|
||||
<script type="text/javascript" src="{{ $unixSrc }}" defer></script>
|
Loading…
Reference in New Issue
Block a user