forked from ofekashery/react-dashboard-design
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_document.tsx
49 lines (45 loc) · 1.22 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
40
41
42
43
44
45
46
47
48
49
import React from 'react';
import Document, { Html, Head, Main, NextScript, DocumentContext } from 'next/document';
import { CssBaseline } from '@geist-ui/react';
class MyDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
const initialProps = await Document.getInitialProps(ctx);
const styles = CssBaseline.flush();
return {
...initialProps,
styles: (
<>
{initialProps.styles}
{styles}
</>
)
};
}
render() {
return (
<Html>
<Head />
<body>
<script
dangerouslySetInnerHTML={{
__html: `
(function(){
if (!window.localStorage) return;
if (window.localStorage.getItem('theme') === 'dark') {
document.documentElement.style.background = '#000';
document.body.style.background = '#000';
} else {
document.documentElement.style.background = '#fff';
document.body.style.background = '#fff';
}
})()`
}}
/>
<Main />
<NextScript />
</body>
</Html>
);
}
}
export default MyDocument;