mirror of
https://github.com/wavetermdev/docusaurus-og.git
synced 2026-08-05 13:46:35 -07:00
fix: fix exceptional cases with docusaurus-fathom
This commit is contained in:
@@ -12,7 +12,13 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
if (ExecutionEnvironment.canUseDOM) {
|
||||
const main = () => {
|
||||
if (
|
||||
HOSTNAMES.length > 0
|
||||
? !HOSTNAMES.includes(window.location.hostname)
|
||||
: window.location.hostname === 'localhost'
|
||||
)
|
||||
return
|
||||
;(function (f: any, a: any, t: string, h: string) {
|
||||
a[h] =
|
||||
a[h] ||
|
||||
@@ -32,15 +38,15 @@ if (ExecutionEnvironment.canUseDOM) {
|
||||
fathom('trackPageview')
|
||||
}
|
||||
|
||||
if (ExecutionEnvironment.canUseDOM) {
|
||||
main()
|
||||
}
|
||||
|
||||
export const onRouteDidUpdate: ClientModule['onRouteDidUpdate'] = ({
|
||||
location,
|
||||
previousLocation,
|
||||
}) => {
|
||||
if (HOSTNAMES.length > 0 && !HOSTNAMES.includes(window.location.hostname))
|
||||
return
|
||||
if (window.location.hostname === 'localhost') return
|
||||
|
||||
if (location.pathname !== previousLocation?.pathname) {
|
||||
if (!!window.fathom && location.pathname !== previousLocation?.pathname) {
|
||||
window.fathom('trackPageview')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ const config = {
|
||||
siteId: 'TEST',
|
||||
scriptUrl: 'https://fathom.status.im/tracker.js',
|
||||
disabled: true,
|
||||
hostnames: ['waku.org'],
|
||||
hostnames: ['localhost', 'waku.org'],
|
||||
},
|
||||
],
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user