The Trans Directory
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: Self-hosted Plausible support (#656)

* Self-hosted Plausible support

* Remove leftover import

authored by

Olivér Falvai and committed by
GitHub
68f53352 359484c1

+15 -16
-9
package-lock.json
··· 32 32 "mdast-util-to-hast": "^13.0.2", 33 33 "mdast-util-to-string": "^4.0.0", 34 34 "micromorph": "^0.4.5", 35 - "plausible-tracker": "^0.3.8", 36 35 "preact": "^10.19.3", 37 36 "preact-render-to-string": "^6.3.1", 38 37 "pretty-bytes": "^6.1.1", ··· 4449 4448 }, 4450 4449 "funding": { 4451 4450 "url": "https://github.com/sponsors/jonschlinkert" 4452 - } 4453 - }, 4454 - "node_modules/plausible-tracker": { 4455 - "version": "0.3.8", 4456 - "resolved": "https://registry.npmjs.org/plausible-tracker/-/plausible-tracker-0.3.8.tgz", 4457 - "integrity": "sha512-lmOWYQ7s9KOUJ1R+YTOR3HrjdbxIS2Z4de0P/Jx2dQPteznJl2eX3tXxKClpvbfyGP59B5bbhW8ftN59HbbFSg==", 4458 - "engines": { 4459 - "node": ">=10" 4460 4451 } 4461 4452 }, 4462 4453 "node_modules/preact": {
-1
package.json
··· 57 57 "mdast-util-to-hast": "^13.0.2", 58 58 "mdast-util-to-string": "^4.0.0", 59 59 "micromorph": "^0.4.5", 60 - "plausible-tracker": "^0.3.8", 61 60 "preact": "^10.19.3", 62 61 "preact-render-to-string": "^6.3.1", 63 62 "pretty-bytes": "^6.1.1",
+1
quartz/cfg.ts
··· 7 7 | null 8 8 | { 9 9 provider: "plausible" 10 + host?: string 10 11 } 11 12 | { 12 13 provider: "google"
-3
quartz/components/scripts/plausible.inline.ts
··· 1 - import Plausible from "plausible-tracker" 2 - const { trackPageview } = Plausible() 3 - document.addEventListener("nav", () => trackPageview())
+14 -3
quartz/plugins/emitters/componentResources.ts
··· 4 4 // @ts-ignore 5 5 import spaRouterScript from "../../components/scripts/spa.inline" 6 6 // @ts-ignore 7 - import plausibleScript from "../../components/scripts/plausible.inline" 8 - // @ts-ignore 9 7 import popoverScript from "../../components/scripts/popover.inline" 10 8 import styles from "../../styles/custom.scss" 11 9 import popoverStyle from "../../components/styles/popover.scss" ··· 103 101 }); 104 102 });`) 105 103 } else if (cfg.analytics?.provider === "plausible") { 106 - componentResources.afterDOMLoaded.push(plausibleScript) 104 + const plausibleHost = cfg.analytics.host ?? "https://plausible.io" 105 + componentResources.afterDOMLoaded.push(` 106 + const plausibleScript = document.createElement("script") 107 + plausibleScript.src = "${plausibleHost}/js/script.manual.js" 108 + plausibleScript.setAttribute("data-domain", location.hostname) 109 + plausibleScript.defer = true 110 + document.head.appendChild(plausibleScript) 111 + 112 + window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) } 113 + 114 + document.addEventListener("nav", () => { 115 + plausible("pageview") 116 + }) 117 + `) 107 118 } else if (cfg.analytics?.provider === "umami") { 108 119 componentResources.afterDOMLoaded.push(` 109 120 const umamiScript = document.createElement("script")