forked from getsentry/sentry-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-ssr.js
25 lines (21 loc) · 835 Bytes
/
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
import React from "react";
import PageContext from "~src/components/pageContext";
export const wrapPageElement = ({ element, props: { pageContext } }) => (
<PageContext.Provider value={pageContext}>{element}</PageContext.Provider>
);
export const onPreRenderHTML = ({getHeadComponents}) => {
if (process.env.NODE_ENV !== 'production')
return
getHeadComponents().forEach(el => {
// Remove inline css. https://github.com/gatsbyjs/gatsby/issues/1526
if (el.type === 'style') {
el.type = 'link'
el.props['href'] = el.props['data-href']
el.props['rel'] = 'stylesheet'
el.props['type'] = 'text/css'
delete el.props['data-href']
delete el.props['dangerouslySetInnerHTML']
delete el.props['children']
}
})
};