2018-09-17 13:55:49 -07:00
|
|
|
import * as React from 'react';
|
|
|
|
import Helmet from 'react-helmet';
|
|
|
|
|
|
|
|
export interface Props {
|
|
|
|
children: any;
|
|
|
|
css: string[];
|
|
|
|
scripts: string[];
|
2018-10-30 10:58:05 -07:00
|
|
|
linkTags: Array<React.LinkHTMLAttributes<HTMLLinkElement>>;
|
|
|
|
metaTags: Array<React.MetaHTMLAttributes<HTMLMetaElement>>;
|
2018-09-17 13:55:49 -07:00
|
|
|
state: string;
|
2018-11-04 10:26:34 -08:00
|
|
|
i18n: string;
|
2018-09-17 13:55:49 -07:00
|
|
|
loadableStateScript: string;
|
|
|
|
}
|
|
|
|
|
2018-10-19 15:03:37 -07:00
|
|
|
const HTML: React.SFC<Props> = ({
|
|
|
|
children,
|
|
|
|
scripts,
|
|
|
|
css,
|
|
|
|
state,
|
2018-11-04 10:26:34 -08:00
|
|
|
i18n,
|
2018-10-30 10:58:05 -07:00
|
|
|
linkTags,
|
|
|
|
metaTags,
|
2018-10-19 15:03:37 -07:00
|
|
|
loadableStateScript,
|
|
|
|
}) => {
|
|
|
|
const head = Helmet.renderStatic();
|
|
|
|
return (
|
|
|
|
<html lang="">
|
|
|
|
<head>
|
|
|
|
<meta charSet="utf-8" />
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
2018-10-30 10:58:05 -07:00
|
|
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
|
|
|
<meta name="apple-mobile-web-app-title" content="Grant.io" />
|
|
|
|
<meta name="application-name" content="Grant.io" />
|
|
|
|
<meta name="mobile-web-app-capable" content="yes" />
|
|
|
|
<meta name="msapplication-TileColor" content="#fff" />
|
|
|
|
<meta name="theme-color" content="#fff" />
|
2018-10-19 15:03:37 -07:00
|
|
|
{/* TODO: import from @fortawesome */}
|
2018-12-28 15:05:34 -08:00
|
|
|
{/* <link
|
2018-10-19 15:03:37 -07:00
|
|
|
rel="stylesheet"
|
|
|
|
href="https://use.fontawesome.com/releases/v5.2.0/css/all.css"
|
|
|
|
integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ"
|
|
|
|
crossOrigin="anonymous"
|
2018-12-28 15:05:34 -08:00
|
|
|
/> */}
|
2018-10-30 10:58:05 -07:00
|
|
|
{/* Custom link & meta tags from webpack */}
|
|
|
|
{linkTags.map((l, idx) => (
|
|
|
|
<link key={idx} {...l as any} />
|
|
|
|
))}
|
|
|
|
{metaTags.map((m, idx) => (
|
|
|
|
<meta key={idx} {...m as any} />
|
|
|
|
))}
|
|
|
|
|
|
|
|
{/* Component link & meta tags */}
|
2018-10-19 15:03:37 -07:00
|
|
|
{head.base.toComponent()}
|
|
|
|
{head.title.toComponent()}
|
|
|
|
{head.meta.toComponent()}
|
|
|
|
{head.link.toComponent()}
|
|
|
|
{head.script.toComponent()}
|
2018-10-30 10:58:05 -07:00
|
|
|
|
2018-10-19 15:03:37 -07:00
|
|
|
{css.map(href => {
|
|
|
|
return <link key={href} rel="stylesheet" href={href} />;
|
|
|
|
})}
|
|
|
|
<script
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
__html: `window.__PRELOADED_STATE__ = ${state}`,
|
|
|
|
}}
|
|
|
|
/>
|
2018-11-04 10:26:34 -08:00
|
|
|
<script
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
__html: `window.__PRELOADED_I18N__ = ${i18n}`,
|
|
|
|
}}
|
|
|
|
/>
|
2018-10-19 15:03:37 -07:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="app" dangerouslySetInnerHTML={{ __html: children }} />
|
|
|
|
<script dangerouslySetInnerHTML={{ __html: loadableStateScript }} />
|
|
|
|
{scripts.map(src => {
|
|
|
|
return <script key={src} src={src} />;
|
|
|
|
})}
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default HTML;
|