-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy path_document.js
More file actions
32 lines (29 loc) · 743 Bytes
/
Copy path_document.js
File metadata and controls
32 lines (29 loc) · 743 Bytes
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
import Document, { Head, Main, NextScript } from "next/document";
import { extractCritical } from "emotion-server";
export default class MyDocument extends Document {
static getInitialProps({ renderPage }) {
const page = renderPage();
const styles = extractCritical(page.html);
return { ...page, ...styles };
}
constructor(props) {
super(props);
const { __NEXT_DATA__, ids } = props;
if (ids) {
__NEXT_DATA__.ids = ids;
}
}
render() {
return (
<html>
<Head>
<style dangerouslySetInnerHTML={{ __html: this.props.css }} />
</Head>
<body style={{ margin: 0 + "px" }}>
<Main />
<NextScript />
</body>
</html>
);
}
}