-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgatsby-ssr.js
46 lines (39 loc) · 1.35 KB
/
gatsby-ssr.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* Implement Gatsby's SSR (Server Side Rendering) APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/ssr-apis/
*/
// You can delete this file if you're not using it
import React from "react"
import Intercom from "decentraland-gatsby/dist/components/Development/Intercom"
import Segment from "decentraland-gatsby/dist/components/Development/Segment"
import Sentry from "decentraland-gatsby/dist/components/Development/Sentry"
export { wrapPageElement, wrapRootElement } from "./gatsby-browser"
/**
* @see https://www.gatsbyjs.com/docs/reference/config-files/gatsby-ssr/#onPreRenderHTML
*/
export function onPreRenderHTML({
getHeadComponents,
replaceHeadComponents,
getPostBodyComponents,
replacePostBodyComponents,
}) {
const headComponents = getHeadComponents().map((component) => {
if (component.type !== "style" || !component.props["data-href"]) {
return component
}
return (
<link
rel="stylesheet"
id={component.props.id}
href={component.props["data-href"]}
/>
)
})
const postBodyComponents = [...getPostBodyComponents()]
postBodyComponents.push(<Segment key="segment" trackPage={false} />)
postBodyComponents.push(<Intercom key="intercom" />)
postBodyComponents.push(<Sentry key="sentry" />)
replaceHeadComponents(headComponents)
replacePostBodyComponents(postBodyComponents)
}