@@ -211,8 +211,49 @@ import Starfield from '../components/Starfield.astro';
211211 }
212212 }
213213
214+ function updateActiveLinks() {
215+ const currentPath = window.location.pathname.replace(/\/$/, '') || '/';
216+ const nav = document.querySelector('nav');
217+ if (!nav) return;
218+
219+ const links = nav.querySelectorAll('a[href]');
220+ links.forEach(link => {
221+ const href = link.getAttribute('href').replace(/\/$/, '') || '/';
222+ const isHomeLink = href === '/'; // Special handling for logo if needed, but assuming nav links
223+
224+ // Skip the logo link which has class "group flex items-center gap-2"
225+ if (link.classList.contains('group') && link.classList.contains('gap-2')) return;
226+
227+ const isActive = currentPath === href;
228+
229+ // Check if it's a mobile menu link (inside #mobile-menu)
230+ const isMobile = link.closest('#mobile-menu');
231+
232+ if (isActive) {
233+ if (isMobile) {
234+ link.classList.remove('text-text-secondary', 'hover:text-white', 'hover:bg-white/5');
235+ link.classList.add('bg-white/10', 'text-white');
236+ } else {
237+ link.classList.remove('text-text-secondary', 'hover:text-text-primary', 'hover:bg-white/5');
238+ link.classList.add('text-text-primary', 'bg-white/10');
239+ }
240+ } else {
241+ if (isMobile) {
242+ link.classList.remove('bg-white/10', 'text-white');
243+ link.classList.add('text-text-secondary', 'hover:text-white', 'hover:bg-white/5');
244+ } else {
245+ link.classList.remove('text-text-primary', 'bg-white/10');
246+ link.classList.add('text-text-secondary', 'hover:text-text-primary', 'hover:bg-white/5');
247+ }
248+ }
249+ });
250+ }
251+
214252 // Run on view transitions (and initial load)
215- document.addEventListener('astro:page-load', setupMobileMenu);
253+ document.addEventListener('astro:page-load', () => {
254+ setupMobileMenu();
255+ updateActiveLinks();
256+ });
216257 </script >
217258
218259 <div class =" pt-24" > <!-- Spacer for floating nav -->
0 commit comments