Skip to content

Commit

Permalink
chore(docs): gatsby-head example using pageContext and setHtmlAttributes
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Nuri <[email protected]>
  • Loading branch information
manusa committed Aug 10, 2022
1 parent 6ecfe4a commit fc9a344
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/docs/reference/built-in-components/gatsby-head.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ exports.onRenderBody = ({ setHtmlAttributes }) => {
}
```

Or even using data provided dynamically through the page context:

```js:title=gatsby-ssr.js
exports.onRenderBody = ({ setHtmlAttributes }) => {
const {
result: { pageContext: { langKey } },
} = loadPageDataSync(pathname);
setHtmlAttributes({ lang: langKey });
}
```

## Additional Resources

- [Adding an SEO component](/docs/how-to/adding-common-features/adding-seo-component)
Expand Down

0 comments on commit fc9a344

Please sign in to comment.