feat(analytics): Goatcounter support ()

* Add options to support goatcounter analytics

* goatcounter: support self-hosted

* Add to configuration docs for goatcounter settings

* use https instead of protocol-relative link for goatcounter js
This commit is contained in:
Tyler Funk 2024-03-06 21:44:34 -06:00 committed by GitHub
parent ba6c7a73d1
commit 3d4a94dda3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 0 deletions
quartz/plugins/emitters

View file

@ -126,6 +126,15 @@ function addGlobalPageResources(
document.head.appendChild(umamiScript)
`)
} else if (cfg.analytics?.provider === "goatcounter") {
componentResources.afterDOMLoaded.push(`
const goatcounterScript = document.createElement("script")
goatcounterScript.src = "${cfg.analytics.scriptSrc ?? "https://gc.zgo.at/count.js"}"
goatcounterScript.async = true
goatcounterScript.setAttribute("data-goatcounter",
"https://${cfg.analytics.websiteId}.${cfg.analytics.host ?? "goatcounter.com"}/count")
document.head.appendChild(goatcounterScript)
`)
}
if (cfg.enableSPA) {