mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Merge pull request #1446 from AkashRajpurohit/master
feat: ✨ customize theme and locale based on query params
This commit is contained in:
commit
7ef4718c4e
2 changed files with 18 additions and 0 deletions
|
|
@ -48,5 +48,14 @@ export default function useLocale() {
|
||||||
}
|
}
|
||||||
}, [locale]);
|
}, [locale]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
const locale = url.searchParams.get('locale');
|
||||||
|
|
||||||
|
if (locale) {
|
||||||
|
saveLocale(locale);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
return { locale, saveLocale, messages, dir, dateLocale };
|
return { locale, saveLocale, messages, dir, dateLocale };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,5 +23,14 @@ export default function useTheme() {
|
||||||
document.body.setAttribute('data-theme', theme);
|
document.body.setAttribute('data-theme', theme);
|
||||||
}, [theme]);
|
}, [theme]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
const theme = url.searchParams.get('theme');
|
||||||
|
|
||||||
|
if (['light', 'dark'].includes(theme)) {
|
||||||
|
saveTheme(theme);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
return [theme, saveTheme];
|
return [theme, saveTheme];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue