-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathgatsby-browser.tsx
More file actions
30 lines (24 loc) · 889 Bytes
/
gatsby-browser.tsx
File metadata and controls
30 lines (24 loc) · 889 Bytes
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
import '@/assets/global.scss'
import '@/assets/prose.scss'
import type { GatsbyBrowser } from 'gatsby'
import Context from '@/contexts'
import Layout from '@/layouts'
import type { PageContext } from 'config/types'
const wrapRootElement: GatsbyBrowser['wrapRootElement'] = ({ element }) => {
return <Context>{element}</Context>
}
const onClientEntry: GatsbyBrowser['onClientEntry'] = async () => {
if (process.env.NODE_ENV === 'development') {
console.log('register service worker')
window.navigator.serviceWorker.register('/append_script.js')
}
const { setAccentColor } = await import('@/utils/accent_color')
setAccentColor()
}
const wrapPageElement: GatsbyBrowser<
Record<string, unknown>,
PageContext
>['wrapPageElement'] = ({ props, element }) => {
return <Layout {...props}>{element}</Layout>
}
export { wrapRootElement, wrapPageElement, onClientEntry }