thunderhub/pages/_document.tsx
Anthony Potdevin 83d9b20205
chore: changes and config for ssr and nextjs (#26)
* test: change docker to yarn

* test: change api handler url

* fix: image imports in public folder

* fix: add path prefix to links

* chore: update deps

* chore: small fixes

* chore: remove prefetch flag

* chore: remove use size hook

* Revert "chore: remove prefetch flag"

This reverts commit ae7ee3bc23.
2020-04-16 10:57:22 +02:00

63 lines
1.4 KiB
TypeScript

import Document, {
DocumentContext,
Html,
Head,
Main,
NextScript,
} from 'next/document';
import { ServerStyleSheet } from 'styled-components';
export default class MyDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
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();
}
}
render() {
return (
<Html>
<Head>
<meta
name="viewport"
content="initial-scale=1.0, width=device-width"
key="viewport"
/>
<meta
name="description"
content="Manage and monitor your lightning network node right inside your browser"
key="description"
/>
<link
href="https://fonts.googleapis.com/css2?family=Manrope:wght@500;700;800&display=swap"
rel="stylesheet"
></link>
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
}