43 lines
1.8 KiB
HTML
43 lines
1.8 KiB
HTML
<!-- START COMPONENT AND JS BUNDLING REFACTOR
|
|
Eventually, all site-specific JavaScript and external JS
|
|
dependencies will be bundled in main.js
|
|
-->
|
|
<!-- Legacy: keep jquery here until component refactor is for scripts in footer.bundle.js that still require it. -->
|
|
{{ $jquery := resources.Get "js/jquery-3.5.0.min.js" }}
|
|
{{ $headerjs := slice $jquery | resources.Concat "js/header.bundle.js" | resources.Fingerprint }}
|
|
|
|
<script type="text/javascript" src="{{ $headerjs.RelPermalink }}"></script>
|
|
|
|
<!-- $productPathData here is buggy - it might not return the current page path due to the context in which .RelPermalink is called -->
|
|
{{ $productPathData := findRE "[^/]+.*?" .RelPermalink }}
|
|
{{ $product := index $productPathData 0 }}
|
|
{{ $currentVersion := index $productPathData 1 }}
|
|
<!-- Get site data -->
|
|
<!-- Load cloudUrls array -->
|
|
{{ $cloudUrls := slice }}
|
|
{{- range.Site.Data.influxdb_urls.cloud.providers }}
|
|
{{- range.regions }}
|
|
{{ $cloudUrls = $cloudUrls | append "{{ safeHTML .url }}" }}
|
|
{{ end -}}
|
|
{{ end -}}
|
|
{{ $products := .Site.Data.products }}
|
|
{{ $influxdb_urls := .Site.Data.influxdb_urls }}
|
|
<!-- Build main.js -->
|
|
{{ with resources.Get "js/main.js" }}
|
|
{{ $opts := dict
|
|
"minify" hugo.IsProduction
|
|
"sourceMap" (cond hugo.IsProduction "" "external")
|
|
"targetPath" "js/main.js"
|
|
"params" (dict "product" $product "currentVersion" $currentVersion "isServer" hugo.IsServer "products" $products "influxdb_urls" $influxdb_urls "cloudUrls" $cloudUrls)
|
|
}}
|
|
{{ with . | js.Build $opts }}
|
|
{{ if hugo.IsProduction }}
|
|
{{ with . | fingerprint }}
|
|
<script src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
|
|
{{ end }}
|
|
{{ else }}
|
|
<script src="{{ .RelPermalink }}"></script>
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|