Skip to content

Instantly share code, notes, and snippets.

@DSchau
Created January 29, 2019 17:06
Show Gist options
  • Select an option

  • Save DSchau/7a6081c7aceca6beb834f7bffc83d2c3 to your computer and use it in GitHub Desktop.

Select an option

Save DSchau/7a6081c7aceca6beb834f7bffc83d2c3 to your computer and use it in GitHub Desktop.
An example of Gatsby SSR APIs
const { Helmet } = require('react-helmet')
const { onRenderBody } = require('gatsby/ssr')
onRenderBody(({ setHeadComponents, setHtmlAttributes, setBodyAttributes }) => {
const helmet = Helmet.renderStatic()
setHtmlAttributes(helmet.htmlAttributes.toComponent())
setBodyAttributes(helmet.bodyAttributes.toComponent())
setHeadComponents([
helmet.title.toComponent(),
helmet.link.toComponent(),
helmet.meta.toComponent(),
helmet.noscript.toComponent(),
helmet.script.toComponent(),
helmet.style.toComponent(),
])
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment