Skip to content

Commit b682bc0

Browse files
kickbelldevclaude
andcommitted
feat: 카테고리 기반 네비게이션 시스템 구현
- NavLink 컴포넌트 추가로 재사용 가능한 네비게이션 링크 구현 - Header 컴포넌트를 카테고리 기반 네비게이션으로 업데이트 - 동적 카테고리 메뉴 생성으로 확장 가능한 구조 제공 - 카테고리별 포스트 개수 표시 지원 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent a3580bc commit b682bc0

File tree

2 files changed

+35
-13
lines changed

2 files changed

+35
-13
lines changed

src/app/_components/Header.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import Link from 'next/link'
22

3-
export default function Header() {
3+
import { getCategoriesWithCount } from '@/entities/categories'
4+
import { getAllPosts } from '@/entities/posts'
5+
6+
import NavLink from './NavLink'
7+
8+
export default async function Header() {
9+
const posts = await getAllPosts()
10+
const categories = await getCategoriesWithCount(posts)
11+
412
return (
513
<header className="sticky top-0 z-50 border-b border-stone-200 bg-white">
614
<nav className="container mx-auto px-5 h-14 flex items-center gap-x-6">
@@ -12,18 +20,16 @@ export default function Header() {
1220
</Link>
1321

1422
<div className="flex items-center space-x-6">
15-
<Link
16-
href="/tags"
17-
className="text-stone-500 hover:text-stone-900 transition-colors"
18-
>
19-
Tags
20-
</Link>
21-
<Link
22-
href="/about"
23-
className="text-stone-500 hover:text-stone-900 transition-colors"
24-
>
25-
About
26-
</Link>
23+
{categories.map((category) => (
24+
<NavLink
25+
key={category.id}
26+
href={`/categories/${category.id}`}
27+
>
28+
{category.name}
29+
</NavLink>
30+
))}
31+
<NavLink href="/tags">Tags</NavLink>
32+
<NavLink href="/about">About</NavLink>
2733
</div>
2834
</nav>
2935
</header>

src/app/_components/NavLink.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Link from 'next/link'
2+
import type { ComponentProps } from 'react'
3+
4+
interface NavLinkProps extends ComponentProps<typeof Link> {}
5+
6+
export default function NavLink({ href, children, ...props }: NavLinkProps) {
7+
return (
8+
<Link
9+
href={href}
10+
className="text-stone-500 hover:text-stone-900 transition-colors"
11+
{...props}
12+
>
13+
{children}
14+
</Link>
15+
)
16+
}

0 commit comments

Comments
 (0)