forked from craigary/nobelium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_app.js
52 lines (47 loc) · 1.72 KB
/
_app.js
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
import 'prismjs/themes/prism.css'
import 'react-notion-x/src/styles.css'
import 'katex/dist/katex.min.css'
import App from 'next/app'
import '@/styles/globals.css'
import '@/styles/notion.css'
import dynamic from 'next/dynamic'
import loadLocale from '@/assets/i18n'
import { ConfigProvider } from '@/lib/config'
import { LocaleProvider } from '@/lib/locale'
import { prepareDayjs } from '@/lib/dayjs'
import { ThemeProvider } from '@/lib/theme'
import Scripts from '@/components/Scripts'
const Ackee = dynamic(() => import('@/components/Ackee'), { ssr: false })
const Gtag = dynamic(() => import('@/components/Gtag'), { ssr: false })
export default function MyApp ({ Component, pageProps, config, locale }) {
return (
<ConfigProvider value={config}>
<Scripts />
<LocaleProvider value={locale}>
<ThemeProvider>
<>
{process.env.VERCEL_ENV === 'production' && config?.analytics?.provider === 'ackee' && (
<Ackee
ackeeServerUrl={config.analytics.ackeeConfig.dataAckeeServer}
ackeeDomainId={config.analytics.ackeeConfig.domainId}
/>
)}
{process.env.VERCEL_ENV === 'production' && config?.analytics?.provider === 'ga' && <Gtag />}
<Component {...pageProps} />
</>
</ThemeProvider>
</LocaleProvider>
</ConfigProvider>
)
}
MyApp.getInitialProps = async ctx => {
const config = typeof window === 'object'
? await fetch('/api/config').then(res => res.json())
: await import('@/lib/server/config').then(module => module.clientConfig)
prepareDayjs(config.timezone)
return {
...App.getInitialProps(ctx),
config,
locale: await loadLocale('basic', config.lang)
}
}