mirror of
https://github.com/Speyll/anemone.git
synced 2024-11-15 02:26:34 +00:00
21 lines
No EOL
454 B
JavaScript
21 lines
No EOL
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(); |