export default function renderHtmlPage(store, html = '') { const head = Helmet.rewind(); const assets = global.webpackIsomorphicTools.assets(); let page = `<!DOCTYPE html><html ${head.htmlAttributes.toString()}>`; page += '<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">'; page += '<meta http-equiv="X-UA-Compatible" content="IE=edge"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">'; page += head.base.toString() + head.title.toString() + head.meta.toString() + head.link.toString(); page += Object.keys(assets.styles).map(style => `<link href="${assets.styles[style]}" rel="stylesheet" type="text/css">` ).join(''); page += `</head><body><div id="app"><div>${html}</div></div>`; if (store) { page += `<script type="text/javascript">window.__INITIAL_STATE__=${serialize(store.getState())}</script>`; } page += Object.keys(assets.javascript).reverse().map(script => `<script src="${assets.javascript[script]}"></script>` ).join(''); page += head.script.toString(); page += '</body></html>'; return page; }
render() { const { component, store } = this.props const head = Helmet.rewind() const htmlAttributes = head.htmlAttributes.toComponent() return ( <html lang={htmlAttributes.lang}> <head> <meta charSet="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="shortcut icon" href="/favicon.ico" /> {head.title.toComponent()} {head.meta.toComponent()} {head.link.toComponent()} {head.script.toComponent()} {this.styles} </head> <body> <div id="root" dangerouslySetInnerHTML={{ __html: renderToString(component) }} /> <script dangerouslySetInnerHTML={{ __html: `window.__PRELOADED_STATE__=${serialize(store.getState())};` }} /> {this.scripts} </body> </html> ) }
html: helmet.htmlAttributes.toString(), head: helmet.title.toString() +
htmlAttributes: helmet.htmlAttributes.toString(), bodyAttributes: helmet.bodyAttributes.toString(), head: head.join(''), .replace('<html lang="en">', '<html ' + whatGoesInside.htmlAttributes + '>') .replace('</head>', whatGoesInside.head + '</head>') .replace('<body>', '<body ' + whatGoesInside.bodyAttributes + '>')
htmlAttributes: head.htmlAttributes.toString(), title: head.title.toString(), meta: head.meta.toString(),
<html ${helmet.htmlAttributes.toString()}> <head> ${helmet.title.toString()}
html: helmet.htmlAttributes.toString(), title: helmet.title.toString(), meta: helmet.meta.toString(),
const Html = ({ store, htmlContent }: Props): Element<'html'> => { const attrs = head.htmlAttributes.toComponent(); const { lang, ...rest } = attrs || {}; const assets = webpackIsomorphicTools.assets();
html: helmet.htmlAttributes.toString(), title: helmet.title.toString(), meta: helmet.meta.toString(),
const attrs = head.htmlAttributes.toComponent();