forked from graphprotocol/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_document.tsx
39 lines (34 loc) · 1.14 KB
/
_document.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
import Document, { DocumentContext, DocumentInitialProps, Head, Html, Main, NextScript } from 'next/document'
import { defaultLocale, extractLocaleFromRouter, getHtmlAttributesForLocale, Locale } from '@edgeandnode/gds'
type MyDocumentProps = DocumentInitialProps & {
locale: Locale | null
}
export default class MyDocument extends Document<MyDocumentProps> {
static async getInitialProps(context: DocumentContext) {
const { locale } = extractLocaleFromRouter(context)
const initialProps = await Document.getInitialProps(context)
return {
...initialProps,
locale: locale ?? defaultLocale,
}
}
render() {
const { locale } = this.props
return (
<Html {...getHtmlAttributesForLocale(locale)} data-theme="dark">
<Head>
<link
rel="preconnect"
href={`https://${process.env.ALGOLIA_APP_ID}-dsn.algolia.net`}
crossOrigin="anonymous"
/>
<link rel="icon" type="image/png" href="https://storage.googleapis.com/graph-web/favicon.png" />
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}