Skip to content

Commit 2973aa1

Browse files
authored
fix: header view selection (#12)
1 parent 9409fec commit 2973aa1

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

components/header.tsx

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,21 @@ export function Header() {
8787
</div>
8888
<div className="hidden items-center gap-6 lg:flex">
8989
<div className="flex items-center gap-8">
90-
{navigation.map((item) => (
91-
<Link
92-
key={item.name}
93-
href={item.href}
94-
className={cn(
95-
"text-sm font-medium transition-colors hover:text-primary",
96-
pathname === item.href
97-
? "text-foreground"
98-
: "text-muted-foreground"
99-
)}
100-
>
101-
{item.name}
102-
</Link>
103-
))}
90+
{navigation.map((item) => {
91+
const isActive = pathname === item.href || pathname === `${item.href}/`
92+
return (
93+
<Link
94+
key={item.name}
95+
href={item.href}
96+
className={cn(
97+
"text-sm font-medium transition-colors hover:text-primary",
98+
isActive ? "text-foreground" : "text-muted-foreground"
99+
)}
100+
>
101+
{item.name}
102+
</Link>
103+
)
104+
})}
104105
</div>
105106
<ThemeToggle />
106107
</div>
@@ -116,21 +117,22 @@ export function Header() {
116117
style={{ top: headerOffset }}
117118
>
118119
<div className="section-container space-y-1 py-6">
119-
{navigation.map((item) => (
120-
<Link
121-
key={item.name}
122-
href={item.href}
123-
className={cn(
124-
"block rounded-md px-3 py-2 text-base font-medium transition-colors hover:bg-accent",
125-
pathname === item.href
126-
? "bg-accent text-foreground"
127-
: "text-muted-foreground"
128-
)}
129-
onClick={() => setMobileMenuOpen(false)}
130-
>
131-
{item.name}
132-
</Link>
133-
))}
120+
{navigation.map((item) => {
121+
const isActive = pathname === item.href || pathname === `${item.href}/`
122+
return (
123+
<Link
124+
key={item.name}
125+
href={item.href}
126+
className={cn(
127+
"block rounded-md px-3 py-2 text-base transition-colors hover:bg-accent",
128+
isActive ? "bg-accent text-foreground" : "text-muted-foreground"
129+
)}
130+
onClick={() => setMobileMenuOpen(false)}
131+
>
132+
{item.name}
133+
</Link>
134+
)
135+
})}
134136
</div>
135137
</div>,
136138
document.body

0 commit comments

Comments
 (0)