-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy path_document.js
More file actions
43 lines (37 loc) · 1.43 KB
/
_document.js
File metadata and controls
43 lines (37 loc) · 1.43 KB
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
import Document, { Html, Head, Main, NextScript } from 'next/document'
import { server, xahauNetwork } from '../utils'
class MyDocument extends Document {
static async getInitialProps(ctx) {
const originalRenderPage = ctx.renderPage
// Run the React rendering logic synchronously
ctx.renderPage = () =>
originalRenderPage({
// Useful for wrapping the whole react tree
enhanceApp: (App) => App,
// Useful for wrapping in a per-page basis
enhanceComponent: (Component) => Component
})
// Run the parent `getInitialProps`, it now includes the custom `renderPage`
const initialProps = await Document.getInitialProps(ctx)
const cookieTheme = ctx.req?.cookies?.theme ?? null
const logoPath = server.includes('bithomp') ? '' : '/images/' + (xahauNetwork ? 'xahauexplorer' : 'xrplexplorer')
return { ...initialProps, cookieTheme, logoPath }
}
render() {
return (
<Html>
<Head>
<link rel="icon" href={this.props.logoPath + '/favicon.ico'} />
{/* <meta name="theme-color" content="#000000" /> */}
<link rel="apple-touch-icon" href={this.props.logoPath + '/apple-touch-icon.png'} />
<link rel="manifest" href="/manifest.json" />
</Head>
<body data-networkname={process.env.NEXT_PUBLIC_NETWORK_NAME}>
<Main />
<NextScript />
</body>
</Html>
)
}
}
export default MyDocument