Min version is now v0.124.0. Using site.Config.Services.GoogleAnalytics.ID, hugo.IsMultilingual and hugo.yaml etc.

This commit is contained in:
Fredrik Jonsson 2024-08-14 14:27:12 +02:00
commit 2ae8ee84ee
2 changed files with 9 additions and 10 deletions

View file

@ -9,7 +9,7 @@
</svg>
</button>
<div class="mobile-nav__sheet link-inverted link-nav" id="sheet" aria-hidden="true">
<div class="mobile-nav__region">{{ if site.IsMultiLingual }}{{ partial "language-selector.html" . }}{{ end }}</div>
<div class="mobile-nav__region">{{ if hugo.IsMultilingual }}{{ partial "language-selector.html" . }}{{ end }}</div>
<nav class="mobile-nav__main-menu" aria-label="{{ i18n "menu_title" }}">
<ul class="mobile-nav__navbar">
{{ if site.Menus.main -}}

View file

@ -1,4 +1,3 @@
{{ $gaid := (or site.Config.Services.GoogleAnalytics.ID site.GoogleAnalytics) -}}
{{ $opts := dict
"minify" true
"params" (dict
@ -6,7 +5,7 @@
"piwikTrackerUrl" site.Params.piwikTrackerUrl
"piwikSiteID" site.Params.piwikSiteID
"plausibleSiteID" site.Params.plausibleSiteID
"GoogleAnalytics" $gaid) -}}
"GoogleAnalytics" site.Config.Services.GoogleAnalytics.ID) -}}
{{ if eq hugo.Environment "development" -}}
{{ $opts = merge $opts (dict "minify" false) -}}
{{ end -}}
@ -20,7 +19,7 @@
<script async defer data-domain="{{ site.Params.plausibleSiteID }}" src="{{ site.Params.plausibleTrackerURL | default "https://plausible.io/js/plausible.js" }}"></script>
{{ end -}}
{{ if $gaid -}}
{{ if site.Config.Services.GoogleAnalytics.ID -}}
{{ $script := resources.Get "js/tracking.js" | js.Build $opts | fingerprint -}}
<script src="{{ $script.RelPermalink }}"></script>
{{ template "_internal/google_analytics.html" . }}