2020-09-09 12:16:01 +03:00
|
|
|
import Document, { Html, Head, Main, NextScript } from "next/document";
|
|
|
|
|
2020-04-09 00:29:13 +03:00
|
|
|
import { extractCritical } from "@emotion/server";
|
2020-02-19 09:30:47 +03:00
|
|
|
|
|
|
|
export default class MyDocument extends Document {
|
2020-09-09 12:16:01 +03:00
|
|
|
static async getInitialProps(ctx) {
|
|
|
|
const initialProps = await Document.getInitialProps(ctx);
|
|
|
|
const styles = extractCritical(initialProps.html);
|
|
|
|
return {
|
|
|
|
...initialProps,
|
|
|
|
styles: (
|
|
|
|
<>
|
|
|
|
{initialProps.styles}
|
|
|
|
<style
|
|
|
|
data-emotion-css={styles.ids.join(" ")}
|
|
|
|
dangerouslySetInnerHTML={{ __html: styles.css }}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
};
|
2020-02-19 09:30:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2020-09-09 12:16:01 +03:00
|
|
|
<Html>
|
|
|
|
<Head />
|
2020-02-19 09:30:47 +03:00
|
|
|
<body>
|
|
|
|
<Main />
|
|
|
|
<NextScript />
|
|
|
|
</body>
|
2020-09-09 12:16:01 +03:00
|
|
|
</Html>
|
2020-02-19 09:30:47 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|