Skip to content

Commit af58f09

Browse files
committed
fix: dark mode initialization in incognito window
1 parent ae25694 commit af58f09

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/layouts/BaseLayout.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const pathname = Astro.url.pathname;
2424
: 'light';
2525
};
2626
const isDark = getThemePreference() === 'dark';
27-
document.documentElement.classList[isDark ? 'add' : 'remove']('dark');
2827

2928
if (typeof localStorage !== 'undefined') {
3029
const observer = new MutationObserver(() => {
@@ -36,6 +35,8 @@ const pathname = Astro.url.pathname;
3635
attributeFilter: ['class'],
3736
});
3837
}
38+
39+
document.documentElement.classList[isDark ? 'add' : 'remove']('dark');
3940
</script>
4041

4142
<html lang="en">

0 commit comments

Comments
 (0)