chore: make theme cookie expire after 365 days
This commit is contained in:
parent
1dd64af4ed
commit
3972340fe7
1 changed files with 2 additions and 2 deletions
|
@ -16,13 +16,13 @@ export const ThemeProvider = (props: Props) => {
|
|||
|
||||
useEffect(() => {
|
||||
if (theme) {
|
||||
cookies.set('theme', theme || initialTheme || 'light', { path: '/' });
|
||||
cookies.set('theme', theme || initialTheme || 'light', { path: '/', expires: 365 });
|
||||
document.body.dataset.bsTheme = theme;
|
||||
} else if (!cookies.get('theme')) {
|
||||
// Detect system theme
|
||||
const systemTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||
setDarkMode(systemTheme === 'dark');
|
||||
cookies.set('theme', systemTheme, { path: '/' });
|
||||
cookies.set('theme', systemTheme, { path: '/', expires: 365 });
|
||||
document.body.dataset.bsTheme = systemTheme;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue