rickvanlieshout.com/html.js

39 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-03-11 23:28:19 +01:00
import React from 'react'
import Helmet from 'react-helmet'
2016-06-03 01:32:38 +02:00
import { prefixLink } from 'gatsby-helpers'
const BUILD_TIME = new Date().getTime()
2016-03-11 23:28:19 +01:00
module.exports = React.createClass({
2016-06-03 01:32:38 +02:00
displayName: 'HTML',
propTypes: {
body: React.PropTypes.string,
2016-03-21 18:03:01 +01:00
},
render() {
2016-06-03 01:32:38 +02:00
const {body, route} = this.props
const {title} = Helmet.rewind()
2016-06-06 17:01:16 +02:00
const font = <link href='https://fonts.googleapis.com/css?family=Roboto:400,400italic,500,700&subset=latin,cyrillic' rel='stylesheet' type='text/css' />
2016-06-03 01:32:38 +02:00
let css
2016-03-21 18:03:01 +01:00
if (process.env.NODE_ENV === 'production') {
2016-07-30 01:05:32 +02:00
css = <style dangerouslySetInnerHTML={ { __html: require('!raw!./public/styles.css')} } />
2016-03-21 18:03:01 +01:00
}
2016-03-11 23:28:19 +01:00
2016-03-21 18:03:01 +01:00
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
2016-06-03 01:32:38 +02:00
<meta name="viewport" content="width=device-width, initial-scale=1.0 maximum-scale=5.0" />
{ title.toComponent() }
2016-06-06 17:01:16 +02:00
{ font }
{ css }
2016-03-21 18:03:01 +01:00
</head>
<body>
<div id="react-mount" dangerouslySetInnerHTML={ { __html: this.props.body} } />
2016-06-03 01:32:38 +02:00
<script src={ prefixLink(`/bundle.js?t=${BUILD_TIME}`) } />
2016-03-21 18:03:01 +01:00
</body>
</html>
)
},
})