Skip to content

Commit

Permalink
feat: pathname in SSR APIs when in develop (#12995)
Browse files Browse the repository at this point in the history
Update the docs for this change: #9792.
It's not a breaking change.
It also adds the pathname to `onRenderBody` and `onPreRenderHTML` in developer.
  • Loading branch information
neo authored and pieh committed Apr 13, 2019
1 parent e385a47 commit 077a9c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/gatsby/cache-dir/api-ssr-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Redux, css-in-js libraries, etc. that need custom setups for server
* rendering.
* @param {Object} $0
* @param {string} $0.pathname The pathname of the page currently being rendered.
* @param {function} $0.replaceBodyHTMLString Call this with the HTML string
* you render. **WARNING** if multiple plugins implement this API it's the
* last plugin that "wins". TODO implement an automated warning against this.
Expand Down Expand Up @@ -99,6 +100,7 @@ exports.onRenderBody = true
* replace head components to be rendered in your `html.js`. This is useful if
* you need to reorder scripts or styles added by other plugins.
* @param {Object} $0
* @param {string} $0.pathname The pathname of the page currently being rendered.
* @param {Array<ReactNode>} $0.getHeadComponents Returns the current `headComponents` array.
* @param {function} $0.replaceHeadComponents Takes an array of components as its
* first argument which replace the `headComponents` array which is passed
Expand Down
2 changes: 2 additions & 0 deletions packages/gatsby/cache-dir/develop-static-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export default (pagePath, callback) => {
setPreBodyComponents,
setPostBodyComponents,
setBodyProps,
pathname: pagePath,
})

apiRunner(`onPreRenderHTML`, {
Expand All @@ -93,6 +94,7 @@ export default (pagePath, callback) => {
replacePreBodyComponents,
getPostBodyComponents,
replacePostBodyComponents,
pathname: pagePath,
})

const htmlElement = React.createElement(Html, {
Expand Down

0 comments on commit 077a9c8

Please sign in to comment.