Files
transform/pages/_document.tsx
Ritesh Kumar 1bd559514b Transform 2.0 (#101)
* feat(init): added EditorPanel with prettier, copy and settings support

* chore(static): ignore static

* feat: added navigator

* feat:

* feat(settings): added sessionStorage support for settings

* feat(message): add messaging support in editors

* feat(preview): added support for preview panel

* fix(settings): use localstorage for settings instead of session storage

* feat:

* feat(css-to-js): implemented React section

* feat(schema): add json to schema conversions

* feat(others): implemented xml, yaml and markdown conversions

* feat(babel): added flow to typescript converter

* feat(graphql): implemented graphql to typescript

* feat(graphql): added some transformations

* fix: add support for different default value in one language

* feat(graphql): added components, resolver signatures and mongodb

* feat:

* scala case class

* fix(memory): worker-loader patch applied to fix memory overflow crash

* feat: added json schema to typescript

*     icon: <GraphQLIcon />,

* feat(navigator): shorter naming and new categories

* route fixes

* navigator

* perf(workers): create separate file and remove fallback

* fix(navigator): completed

* build(snack):

* fixes

* fixes

* fix(safari):

* added json-to-mobx-state tree

* fix(native): snacksession

* fixes

* added logo

* navigator

* fixes

* custom header

* fixes

* refactor(settings): move settings to left side

* feat: set up redirects

* feat(seo): added title and description

* feat(error): added custom error page

* ga-script

* feat:

* fixes

* fixe

* fixes

* fixes

* fix:
2019-07-18 19:07:48 +05:30

77 lines
1.6 KiB
TypeScript

import React from "react";
import Document, { Head, Main, NextScript } from "next/document";
import { extractStyles } from "evergreen-ui";
interface DocumentProps {
css: string;
hydrationScript: React.ReactChild;
}
function trackingScript() {
(function(i, s, o, g, r, a, m) {
i["GoogleAnalyticsObject"] = r;
(i[r] =
i[r] ||
function() {
(i[r].q = i[r].q || []).push(arguments);
}),
// @ts-ignore
(i[r].l = 1 * new Date());
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m);
})(
window,
document,
"script",
"https://www.google-analytics.com/analytics.js",
"ga"
);
// @ts-ignore
window.ga("create", "UA-60624235-5", "auto");
// @ts-ignore
window.ga("send", "pageview");
}
export default class MyDocument extends Document<DocumentProps> {
static getInitialProps({ renderPage }) {
const page = renderPage();
const { css, hydrationScript } = extractStyles();
return {
...page,
css,
hydrationScript
};
}
componentDidMount(): void {
trackingScript();
}
render() {
const { css, hydrationScript } = this.props;
return (
<html>
<Head>
<meta charSet="utf-8" />
<meta
name="google-site-verification"
content="bjJSOEahdert-7mwVScrwTTUVR3nSe0bEj5YjevUNn0"
/>
<style dangerouslySetInnerHTML={{ __html: css }} />
</Head>
<body>
<Main />
{hydrationScript}
<NextScript />
</body>
</html>
);
}
}