forked from vote4hk/warsinhk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgatsby-ssr.js
More file actions
32 lines (31 loc) · 850 Bytes
/
Copy pathgatsby-ssr.js
File metadata and controls
32 lines (31 loc) · 850 Bytes
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
/**
* Implement Gatsby's SSR (Server Side Rendering) APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/ssr-apis/
*/
import React from "react"
import "@/i18n"
import I18nWrapper from "@/components/I18nWrapper"
import RootLayout from "@/components/templates/RootLayout"
import { removePathTrailingSlash } from "@/utils/urlHelper"
export const wrapPageElement = ({ element, props }) => {
// remove the trailing slash
const fullPath = removePathTrailingSlash(props.location.pathname)
const path = fullPath.replace(/^\/en(?!\w)/, "") || "/"
return (
<>
<RootLayout
initialStore={{
route: {
path,
fullPath,
},
}}
>
<I18nWrapper locale={props.pageContext.locale} ssr={true}>
{element}
</I18nWrapper>
</RootLayout>
</>
)
}