-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-ssr.js
36 lines (32 loc) · 886 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 '@/common/styles/global.css';
import 'typeface-baloo-bhaina-2';
import 'typeface-open-sans';
import Layout from '@/common/components/layout/Layout';
import React from 'react';
export const onRenderBody = ({ setBodyAttributes, setHtmlAttributes }) => {
const isBrowser = typeof window !== 'undefined';
if (
isBrowser &&
(window.localStorage.getItem('theme') === 'dark' ||
(!('theme' in window.localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches))
) {
setHtmlAttributes({
className: 'dark',
lang: 'en',
});
} else {
setHtmlAttributes({
lang: 'en',
});
}
setBodyAttributes({
className: 'bg-white dark:bg-gray-900 transition-colors',
});
};
export const wrapRootElement = ({ element }) => {
return (
<React.StrictMode>
<Layout>{element}</Layout>
</React.StrictMode>
);
};