forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_document.js
More file actions
75 lines (71 loc) · 2.66 KB
/
_document.js
File metadata and controls
75 lines (71 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// ./pages/_document.js
import React from 'react';
import Document, { Main, NextScript, Head } from 'next/document';
import { ServerStyleSheet } from 'styled-components';
export default class MyDocument 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();
}
}
render() {
const head = {
description:
'CodeSandbox is an online code editor with a focus on creating and sharing web application projects',
image: 'https://codesandbox.io/static/img/banner.png',
};
return (
<html lang="en">
<Head>
<meta name="og:title" content={head.title} />
<meta name="og:description" content={head.description} />
<meta name="twitter:description" content={head.description} />
<meta name="description" content={head.description} />
<meta name="og:image" content={head.image} />
<meta name="twitter:image:src" content={head.image} />
<meta
name="keywords"
content="react, codesandbox, editor, code, javascript, playground, sharing, spa, single, page, application, web, application, frontend, front, end"
/>
<meta name="referrer" content="origin" />
<meta name="theme-color" content="#6CAEDD" />
<meta property="og:type" content="website" />
<meta property="og:author" content="https://codesandbox.io" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="twitter:image:width" content="1200" />
<meta property="twitter:image:height" content="630" />
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:site" content="@codesandbox" />
<meta property="twitter:creator" content="@codesandbox" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,700|Poppins:400,700"
rel="stylesheet"
/>
</Head>
<body>
<Main />
<NextScript />
</body>
</html>
);
}
}