mirror of
https://github.com/zaaarf/friendenstein.git
synced 2024-11-22 23:44:53 +01: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(); |