jessicamarcus
10/17/2017 - 7:14 PM

use typekit with gatsby

use typekit with gatsby

const typekit = {
  '__html': `
    try{Typekit.load({ async: true });}catch(e){}
    `
}

module.exports = class HTML extends React.Component {
  render() {
    let css
    if (process.env.NODE_ENV === `production`) {
      css = (
        <style
          id="gatsby-inlined-css"
          dangerouslySetInnerHTML={{ __html: stylesStr }}
        />
      )
    }
    return (
      <html>
        <head>
          <meta charSet="utf-8" />
          <meta httpEquiv="x-ua-compatible" content="ie=edge" />
          <meta
            name="viewport"
            content="width=device-width, initial-scale=1, shrink-to-fit=no"
          />
          <script src="https://use.typekit.net/whatever.js"></script>
          <script type='text/javascript' dangerouslySetInnerHTML={typekit}></script>

          {this.props.headComponents}
          {css}
        </head>
      <body>
          {this.props.preBodyComponents}
          <div
            key={`body`}
            id="___gatsby"
            dangerouslySetInnerHTML={{ __html: this.props.body }}
          />
          {this.props.postBodyComponents}
          <script type='text/javascript' dangerouslySetInnerHTML={snapEngage}></script>
        </body>
      </html>
    )
  }
}