Skip to content

Commit

Permalink
fix: still track on load
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-psi committed Jan 22, 2024
1 parent f5f0fb9 commit cede666
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions website/.vitepress/theme/plugin/goatcounter.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
function mountGoatcounter(id: string) {
// @ts-ignore
if (window.goatcounter || window.location.hostname === 'localhost') {
return
return;
}

const script = document.createElement("script")
const script = document.createElement("script");

script.dataset.goatcounter = `https://${id}.goatcounter.com/count`
script.async = true
script.src = "//gc.zgo.at/count.js"

window.goatcounter = { no_onload: true };
script.dataset.goatcounter = `https://${id}.goatcounter.com/count`;
script.async = true;
script.src = "//gc.zgo.at/count.js";

document.head.appendChild(script)
}

export default function ({ id }: { id: string }) {
// eslint-disable-next-line node/prefer-global/process
if (process.env.NODE_ENV === 'production' && id && typeof window !== 'undefined') {
mountGoatcounter(id)
mountGoatcounter(id);
}
}

0 comments on commit cede666

Please sign in to comment.