aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/pages/_document.js
diff options
context:
space:
mode:
authorJacky Zhao <[email protected]>2021-04-11 15:06:48 -0700
committerGitHub <[email protected]>2021-04-11 15:06:48 -0700
commit82bda5ee85efbd2eae25427a839529d5e230eeaa (patch)
tree1f7a88938fd6664a9a048503a5a78d010e3db1e2 /frontend/src/pages/_document.js
parentMerge pull request #72 from jackyzha0/no-ip (diff)
parentreadd preset height (diff)
downloadctrl-v-82bda5ee85efbd2eae25427a839529d5e230eeaa.tar.xz
ctrl-v-82bda5ee85efbd2eae25427a839529d5e230eeaa.zip
Merge pull request #74 from jackyzha0/next-refactor
Diffstat (limited to 'frontend/src/pages/_document.js')
-rw-r--r--frontend/src/pages/_document.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/frontend/src/pages/_document.js b/frontend/src/pages/_document.js
new file mode 100644
index 0000000..0cbd6a3
--- /dev/null
+++ b/frontend/src/pages/_document.js
@@ -0,0 +1,30 @@
+import Document from 'next/document'
+import { ServerStyleSheet } from 'styled-components'
+
+export default class StyledDocument extends Document {
+ static async getInitialProps(ctx) {
+ const sheet = new ServerStyleSheet()
+ const originalRenderPage = ctx.renderPage
+
+ 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()
+ }
+ }
+} \ No newline at end of file