Created
January 29, 2019 17:06
-
-
Save DSchau/7a6081c7aceca6beb834f7bffc83d2c3 to your computer and use it in GitHub Desktop.
An example of Gatsby SSR APIs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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