diff --git a/pages/_document.tsx b/pages/_document.tsx new file mode 100644 index 0000000..42871f5 --- /dev/null +++ b/pages/_document.tsx @@ -0,0 +1,32 @@ +import Document from 'next/document'; +import { ServerStyleSheet } from 'styled-components'; + +class RootDocument extends Document { + static async getInitialProps(ctx: any) { + const sheet = new ServerStyleSheet(); + const originalRenderPage = ctx.renderPage; + + try { + ctx.renderPage = () => + originalRenderPage({ + enhanceApp: (App: any) => (props: any) => + sheet.collectStyles(), + }); + + const initialProps = await Document.getInitialProps(ctx); + return { + ...initialProps, + styles: ( + <> + {initialProps.styles} + {sheet.getStyleElement()} + + ), + }; + } finally { + sheet.seal(); + } + } +} + +export default RootDocument; diff --git a/pages/index.tsx b/pages/index.tsx index b3b0ad9..c3bd7b8 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,9 +1,13 @@ import React from 'react'; +import Head from 'next/head'; import Me from '../components/Me'; import Social from '../components/Social'; const Frontpage: React.FC<{}> = () => ( <> + + Morten Olsen +