11---
22import { Picture } from " astro:assets" ;
33import logoImage from " /public/assets/images/RecursiveZero-White.jpg" ;
4+ const currentPath = Astro .url .pathname ;
5+ const base = import .meta .env .BASE_URL ;
6+
7+ // Helper function to normalize paths for comparison
8+ const normalizePath = (path : string ) => {
9+ return path .endsWith (" /" ) && path !== " /" ? path .slice (0 , - 1 ) : path ;
10+ };
11+
12+ // Helper function to check if a link is active
13+ const isActive = (linkPath : string ) => {
14+ const normalizedCurrent = normalizePath (currentPath );
15+ const normalizedLink = normalizePath (linkPath );
16+
17+ if (linkPath === base ) {
18+ // Home page - exact match
19+ return normalizedCurrent === normalizedLink || normalizedCurrent === base .slice (0 , - 1 );
20+ }
21+
22+ // Other pages - check if current path starts with link path
23+ return normalizedCurrent .startsWith (normalizedLink );
24+ };
425---
526
627<header >
728 <div class =" nav-container w-full" >
829 <nav class =" " >
930 <div class =" mx-5 flex w-full items-center justify-between" >
1031 <h1 class =" text-[1.05rem] font-bold leading-[-0.03em] lg:text-[1.2rem]" >
11- <a href =" / " class =" flex items-center gap-[0.5rem] lg:flex-row" >
32+ <a href ={ base } class =" flex items-center gap-[0.5rem] lg:flex-row" >
1233 <Picture
1334 src ={ logoImage }
1435 formats ={ [" png" , " jpeg" , " jpg" , " webp" ]}
@@ -25,7 +46,14 @@ import logoImage from "/public/assets/images/RecursiveZero-White.jpg";
2546 </h1 >
2647 <ul class =" menu-list flex items-center gap-[1.5rem] lg:flex-row-reverse" >
2748 <!-- <li id="themeToggle">
28- <button class="sunBtn">
49+ <button class="sunBtn">const currentPath = Astro.url.pathname;
50+ const base = import.meta.env.BASE_URL || '/';
51+
52+ // Helper function to create correct paths
53+ const createPath = (path: string) => {
54+ if (path === '/') return base;
55+ return `${base}${path}`.replace(/\/+/g, '/');
56+ };
2957 <i class="fa fa-sun-o" aria-hidden="true">Light</i>
3058 </button>
3159 <button class="moonBtn hidden">
0 commit comments