mirror of
https://github.com/Speyll/anemone.git
synced 2024-11-24 05:46:38 +00:00
21 lines
454 B
JavaScript
21 lines
454 B
JavaScript
|
const setTheme = (theme) => {
|
||
|
document.documentElement.className = theme;
|
||
|
localStorage.setItem('theme', theme);
|
||
|
}
|
||
|
|
||
|
const hasCodeRun = localStorage.getItem('hasCodeRun');
|
||
|
|
||
|
if (!hasCodeRun) {
|
||
|
const defaultTheme = "{{ config.extra.default_theme }}";
|
||
|
setTheme(defaultTheme);
|
||
|
localStorage.setItem('hasCodeRun', 'true');
|
||
|
}
|
||
|
|
||
|
const getTheme = () => {
|
||
|
const theme = localStorage.getItem('theme');
|
||
|
if (theme) {
|
||
|
setTheme(theme);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
getTheme();
|