Chore: Spacing and stuff

This commit is contained in:
looskie
2021-06-22 14:10:58 -04:00
parent 82ff136c9b
commit 98c9ce49ab
5 changed files with 157 additions and 87 deletions

View File

@@ -1,30 +1,29 @@
import Document from 'next/document'
import { ServerStyleSheet } from 'styled-components'
import Document from "next/document";
import { ServerStyleSheet } from "styled-components";
export default class MyDocument extends Document {
static async getInitialProps(ctx) {
const sheet = new ServerStyleSheet(),
originalRenderPage = ctx.renderPage
static async getInitialProps(ctx) {
const sheet = new ServerStyleSheet(),
originalRenderPage = ctx.renderPage;
try {
ctx.renderPage = () =>
originalRenderPage({
enhanceApp: (App) => (props) =>
sheet.collectStyles(<App {...props} />),
})
try {
ctx.renderPage = () =>
originalRenderPage({
enhanceApp: App => props => sheet.collectStyles(<App {...props} />),
});
const initialProps = await Document.getInitialProps(ctx)
return {
...initialProps,
styles: (
<>
{initialProps.styles}
{sheet.getStyleElement()}
</>
),
}
} finally {
sheet.seal()
const initialProps = await Document.getInitialProps(ctx);
return {
...initialProps,
styles: (
<>
{initialProps.styles}
{sheet.getStyleElement()}
</>
),
};
} finally {
sheet.seal();
}
}
}
}
}