This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
website/pages/_app.tsx

40 lines
1.0 KiB
TypeScript
Raw Normal View History

2021-10-24 05:19:39 +02:00
import { useEffect } from 'react'
import { AppProps } from 'next/app'
2021-10-24 05:48:06 +02:00
import { ThemeProvider } from 'next-themes'
2021-10-24 05:19:39 +02:00
import useTranslation from 'next-translate/useTranslation'
2021-10-24 05:48:06 +02:00
import UniversalCookie from 'universal-cookie'
2021-10-24 05:19:39 +02:00
2021-10-24 05:48:06 +02:00
import 'styles/global.css'
2021-10-24 05:19:39 +02:00
2021-10-24 05:48:06 +02:00
import '@fontsource/montserrat/400.css'
import '@fontsource/montserrat/500.css'
import '@fontsource/montserrat/600.css'
import '@fontsource/montserrat/700.css'
2021-10-24 05:19:39 +02:00
import '@fontsource/roboto/400.css'
import '@fontsource/roboto/700.css'
2021-10-24 05:48:06 +02:00
const universalCookie = new UniversalCookie()
2021-10-24 05:19:39 +02:00
2021-10-24 05:48:06 +02:00
/** how long in seconds, until the cookie expires (10 years) */
const COOKIE_MAX_AGE = 10 * 365.25 * 24 * 60 * 60
const Application = ({ Component, pageProps }: AppProps): JSX.Element => {
2021-10-24 05:19:39 +02:00
const { lang } = useTranslation()
useEffect(() => {
2021-10-24 05:48:06 +02:00
universalCookie.set('NEXT_LOCALE', lang, {
path: '/',
maxAge: COOKIE_MAX_AGE
})
2021-10-24 05:19:39 +02:00
}, [lang])
return (
2021-10-24 05:48:06 +02:00
<ThemeProvider attribute='class' defaultTheme='dark'>
<Component {...pageProps} />
</ThemeProvider>
2021-10-24 05:19:39 +02:00
)
}
2021-10-24 05:48:06 +02:00
export default Application