-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gatsby-ssr.tsx
33 lines (26 loc) · 1013 Bytes
/
gatsby-ssr.tsx
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
import { getInitColorSchemeScript } from "@mui/material/styles/CssVarsProvider";
import { Fragment } from "react";
import { SITE_METADATA } from "./src/constants/SITE_METADATA";
import type { GatsbySSR } from "gatsby";
import { WrapPageElement } from "@/layouts/WrapPageElement";
import { WrapRootElement } from "@/layouts/WrapRootElement";
export const onRenderBody: GatsbySSR["onRenderBody"] = ({
setHtmlAttributes,
setPreBodyComponents,
}) => {
setHtmlAttributes({ lang: SITE_METADATA.defaultLanguage });
setPreBodyComponents([
<Fragment key="init-color-scheme-script">
{getInitColorSchemeScript({
defaultMode: "light",
modeStorageKey: "mui-mode-disabled",
})}
</Fragment>,
]);
};
export const wrapRootElement: GatsbySSR["wrapRootElement"] = ({ element }) => {
return <WrapRootElement>{element}</WrapRootElement>;
};
export const wrapPageElement: GatsbySSR["wrapPageElement"] = ({ element }) => {
return <WrapPageElement>{element}</WrapPageElement>;
};