From 8c889a862c82fa8a905c3d834f93cf9a20d7c9bc Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sat, 5 Apr 2025 18:24:29 -0700 Subject: [PATCH] fix initial theme lookup --- static/js/faviconTheme.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/static/js/faviconTheme.js b/static/js/faviconTheme.js index 491f8e7..473d363 100644 --- a/static/js/faviconTheme.js +++ b/static/js/faviconTheme.js @@ -16,8 +16,13 @@ function updateFaviconColor(dark) { } } -// Get the current theme at startup, defaulting to light -const currentTheme = document.documentElement.getAttribute('data-theme') || 'light'; +// Determine the initial theme. +let currentTheme = + localStorage.getItem('theme') || + document.documentElement.getAttribute('data-theme') || + window.matchMedia('(prefers-color-scheme: dark)').matches + ? 'dark' + : 'light'; // Set the favicon color on startup updateFaviconColor(currentTheme === 'dark');