forked from transitive-bullshit/nextjs-notion-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path_app.tsx
65 lines (54 loc) · 1.57 KB
/
_app.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// global styles shared across the entire site
import * as React from 'react'
import type { AppProps } from 'next/app'
import { useRouter } from 'next/router'
import * as Fathom from 'fathom-client'
// used for rendering equations (optional)
import 'katex/dist/katex.min.css'
import posthog from 'posthog-js'
// used for code syntax highlighting (optional)
import 'prismjs/themes/prism-coy.css'
// core styles shared by all of react-notion-x (required)
import 'react-notion-x/src/styles.css'
import 'styles/global.css'
// this might be better for dark mode
// import 'prismjs/themes/prism-okaidia.css'
// global style overrides for notion
import 'styles/notion.css'
// global style overrides for prism theme (optional)
import 'styles/prism-theme.css'
import { bootstrap } from '@/lib/bootstrap-client'
import {
fathomConfig,
fathomId,
isServer,
posthogConfig,
posthogId
} from '@/lib/config'
if (!isServer) {
bootstrap()
}
export default function App({ Component, pageProps }: AppProps) {
const router = useRouter()
React.useEffect(() => {
function onRouteChangeComplete() {
if (fathomId) {
Fathom.trackPageview()
}
if (posthogId) {
posthog.capture('$pageview')
}
}
if (fathomId) {
Fathom.load(fathomId, fathomConfig)
}
if (posthogId) {
posthog.init(posthogId, posthogConfig)
}
router.events.on('routeChangeComplete', onRouteChangeComplete)
return () => {
router.events.off('routeChangeComplete', onRouteChangeComplete)
}
}, [router.events])
return <Component {...pageProps} />
}