mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-25 02:36:20 +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
@ -48,5 +48,14 @@ export default function useLocale() {
|
||||
}
|
||||
}, [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 };
|
||||
}
|
||||
|
@ -23,5 +23,14 @@ export default function useTheme() {
|
||||
document.body.setAttribute('data-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];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user