Support SSR
This commit is contained in:
parent
5058711985
commit
c6066fd038
@ -7,7 +7,9 @@ const ThemeChanger = ({ theme, setTheme, loading }) => {
|
|||||||
const changeTheme = (e, selectedTheme) => {
|
const changeTheme = (e, selectedTheme) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
document.querySelector('html').setAttribute('data-theme', selectedTheme);
|
document.querySelector('html').setAttribute('data-theme', selectedTheme);
|
||||||
localStorage.setItem('gitprofile-theme', selectedTheme);
|
|
||||||
|
typeof window !== 'undefined' &&
|
||||||
|
localStorage.setItem('gitprofile-theme', selectedTheme);
|
||||||
|
|
||||||
setTheme(selectedTheme);
|
setTheme(selectedTheme);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,6 +8,7 @@ export const getInitialTheme = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
typeof window !== 'undefined' &&
|
||||||
!(localStorage.getItem('gitprofile-theme') === null) &&
|
!(localStorage.getItem('gitprofile-theme') === null) &&
|
||||||
config.themeConfig.themes.includes(localStorage.getItem('gitprofile-theme'))
|
config.themeConfig.themes.includes(localStorage.getItem('gitprofile-theme'))
|
||||||
) {
|
) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user