generated from minimal-dev/gatsby-starter-minimal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-ssr.js
36 lines (30 loc) · 813 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
26
27
28
29
30
31
32
33
34
35
36
import React from 'react'
import Layout from './src/components/Layout'
/**
* Implement Gatsby's SSR (Server Side Rendering) APIs in this file.
*
* See: https://www.gatsbyjs.com/docs/ssr-apis/
*/
export const onRenderBody = ({ setHtmlAttributes }) => {
setHtmlAttributes({ lang: 'en' })
}
export const wrapPageElement = ({ element, props }) => {
return <Layout {...props}>{element}</Layout>
}
// Hack, to reorder the helmet components as first in <head> tag
export const onPreRenderHTML = ({
getHeadComponents,
replaceHeadComponents,
}) => {
/**
* @type {any[]} headComponents
*/
const headComponents = getHeadComponents()
headComponents.sort((a) => {
if (a.props && a.props['data-gatsby-head']) {
return -1
}
return 1
})
replaceHeadComponents(headComponents)
}