pidgin/nest

837d728b48d1
Parents 26e94c98c983
Children 82712858eddf
Make asset busting depend on deployment environment

At the moment CSS and JS resources have a cache busting tag at the end of their href/src to force a reload when re-rendered. This is deependant on an unused setting, and is present in prod as well, this is really only a feature for development. So, it's been a PITA when diffing outputs

Testing Done:
I've run the `hugo` and `hugo serve` commands with deployment env between prod and dev, and behaviour is as expected

Reviewed at https://reviews.imfreedom.org/r/145/
--- a/hugo/themes/learn/layouts/404.html Thu Oct 01 20:19:38 2020 -0500
+++ b/hugo/themes/learn/layouts/404.html Thu Oct 01 20:22:01 2020 -0500
@@ -14,16 +14,16 @@
<title>{{ .Scratch.Get "title" }}</title>
- {{ $assetBusting := not .Site.Params.disableAssetsBusting }}
- <link href="{{ "css/nucleus.css" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
- <link href="{{ "css/fontawesome-all.min.css" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
- <link href="{{ "css/hybrid.css" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
- <link href="{{ "css/perfect-scrollbar.min.css" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
- <link href="{{ "css/horsey.css" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
- <link href="{{ "css/theme.css" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
- <link href="{{ "css/hugo-theme.css" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
+ {{ $assetBusting := cond (hugo.IsProduction) "" (print "?" now.Unix) }}
+ <link href="{{ "css/nucleus.css" | relURL }}{{ $assetBusting }}" rel="stylesheet">
+ <link href="{{ "css/fontawesome-all.min.css" | relURL }}{{ $assetBusting }}" rel="stylesheet">
+ <link href="{{ "css/hybrid.css" | relURL }}{{ $assetBusting }}" rel="stylesheet">
+ <link href="{{ "css/perfect-scrollbar.min.css" | relURL }}{{ $assetBusting }}" rel="stylesheet">
+ <link href="{{ "css/horsey.css" | relURL }}{{ $assetBusting }}" rel="stylesheet">
+ <link href="{{ "css/theme.css" | relURL }}{{ $assetBusting }}" rel="stylesheet">
+ <link href="{{ "css/hugo-theme.css" | relURL }}{{ $assetBusting }}" rel="stylesheet">
{{ with .Site.Params.themeVariant }}
- <link href="{{ (printf "css/theme-%s.css" .) | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
+ <link href="{{ (printf "css/theme-%s.css" .) | relURL }}{{ $assetBusting }}" rel="stylesheet">
{{ end }}
<style type="text/css">
--- a/hugo/themes/learn/layouts/partials/header.html Thu Oct 01 20:19:38 2020 -0500
+++ b/hugo/themes/learn/layouts/partials/header.html Thu Oct 01 20:22:01 2020 -0500
@@ -8,19 +8,19 @@
{{ partial "favicon.html" . }}
<title>{{ .Title }} :: {{ .Site.Title }}</title>
- {{ $assetBusting := not .Site.Params.disableAssetsBusting }}
- <link href="{{ "css/nucleus.css" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
- <link href="{{ "css/fontawesome-all.min.css" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
- <link href="{{ "css/hybrid.css" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
- <link href="{{ "css/perfect-scrollbar.min.css" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
- <link href="{{ "css/auto-complete.css" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
- <link href="{{ "css/theme.css" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
- <link href="{{ "css/hugo-theme.css" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
+ {{ $assetBusting := cond (hugo.IsProduction) "" (print "?" now.Unix) }}
+ <link href="{{ "css/nucleus.css" | relURL }}{{ $assetBusting }}" rel="stylesheet">
+ <link href="{{ "css/fontawesome-all.min.css" | relURL }}{{ $assetBusting }}" rel="stylesheet">
+ <link href="{{ "css/hybrid.css" | relURL }}{{ $assetBusting }}" rel="stylesheet">
+ <link href="{{ "css/perfect-scrollbar.min.css" | relURL }}{{ $assetBusting }}" rel="stylesheet">
+ <link href="{{ "css/auto-complete.css" | relURL }}{{ $assetBusting }}" rel="stylesheet">
+ <link href="{{ "css/theme.css" | relURL }}{{ $assetBusting }}" rel="stylesheet">
+ <link href="{{ "css/hugo-theme.css" | relURL }}{{ $assetBusting }}" rel="stylesheet">
{{ with .Site.Params.themeVariant }}
- <link href="{{ (printf "css/theme-%s.css" .) | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
+ <link href="{{ (printf "css/theme-%s.css" .) | relURL }}{{ $assetBusting }}" rel="stylesheet">
{{ end }}
- <script src="{{ "js/jquery-2.x.min.js"| relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}"></script>
+ <script src="{{ "js/jquery-2.x.min.js"| relURL }}{{ $assetBusting }}"></script>
<style type="text/css">
:root #header + #content > #left > #rlblock_left{
--- a/hugo/themes/learn/layouts/partials/search.html Thu Oct 01 20:19:38 2020 -0500
+++ b/hugo/themes/learn/layouts/partials/search.html Thu Oct 01 20:22:01 2020 -0500
@@ -3,9 +3,9 @@
<input data-search-input id="search-by" type="search" placeholder="{{ T "Search-placeholder" }}">
<span data-search-clear=""><i class="fas fa-times"></i></span>
</div>
-{{ $assetBusting := not .Site.Params.disableAssetsBusting }}
-<script type="text/javascript" src="{{ "js/lunr.min.js" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}"></script>
-<script type="text/javascript" src="{{ "js/auto-complete.js" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}"></script>
+{{ $assetBusting := cond (hugo.IsProduction) "" (print "?" now.Unix) }}
+<script type="text/javascript" src="{{ "js/lunr.min.js" | relURL }}{{ $assetBusting }}"></script>
+<script type="text/javascript" src="{{ "js/auto-complete.js" | relURL }}{{ $assetBusting }}"></script>
<script type="text/javascript">
{{ if .Site.IsMultiLingual }}
var baseurl = "{{ .Site.BaseURL }}{{ .Site.LanguagePrefix }}";
@@ -13,4 +13,4 @@
var baseurl = "{{ .Site.BaseURL }}";
{{ end }}
</script>
-<script type="text/javascript" src="{{ "js/search.js" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}"></script>
+<script type="text/javascript" src="{{ "js/search.js" | relURL }}{{ $assetBusting }}"></script>