{"size": 1628, "ext": "js", "max_stars_repo_path": "src/components/DefaultTemplate/DefaultTemplate.js", "max_stars_repo_name": "mattwoodage/react-ssr", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/DefaultTemplate/DefaultTemplate.js", "max_issues_repo_name": "mattwoodage/react-ssr", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/DefaultTemplate/DefaultTemplate.js", "max_forks_repo_name": "mattwoodage/react-ssr", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.3076923077, "max_line_length": 80, "alphanum_fraction": 0.5872235872}
import React from 'react'

class Html extends React.Component {
  render () {
    const state = this.props.state
    const injectedState = `window.__STATE = ${JSON.stringify(state)};`
    let { title, meta, link, bodyAttrs, htmlAttrs } = this.props.document

    try {
      const Helmet = require('react-helmet')
      const helmet = Helmet.renderStatic()
      title = title || helmet.title.toComponent()
      meta = meta || helmet.meta.toComponent()
      link = link || helmet.link.toComponent()
      htmlAttrs = htmlAttrs || helmet.htmlAttributes.toComponent()
      bodyAttrs = bodyAttrs || helmet.bodyAttributes.toComponent()
    } catch (e) {
      // Helmet wasn't given to us...
      // for now, we'll silently skip
    }

    return (
      <html lang='en-gb' {...htmlAttrs}>
        <head>
          {title}
          {meta}
          {link}
          <meta charSet='utf-8' />
          <meta httpEquiv='X-UA-Compatible' content='IE=edge' />
          <meta name='viewport' content='width=device-width, initial-scale=1' />
          <meta name='mobile-web-app-capable' content='yes' />
          <link href='/assets/styles.css' rel='stylesheet' />
          <link rel='icon' type='image/x-icon' href='/favicon.ico' />

          <script dangerouslySetInnerHTML={{__html: this.props.globals}} />
        </head>
        <body {...bodyAttrs}>
          <div id='root'>{this.props.children}</div>
          <script dangerouslySetInnerHTML={{__html: injectedState}} />
          <script src='/assets/bundle.js' />
        </body>
      </html>
    )
  }
}

Html.defaultProps = {
  document: {}
}

export default Html
