Categories
{/* 로딩 중일 때 스켈레톤 UI */}
{!categories && (
{[1, 2, 3].map((i) => (
))}
)}
{/* 실제 카테고리 렌더링 */}
{categories?.map((cat) => {
// 현재 카테고리(또는 자식)가 선택되었는지 확인
const isActive = pathname.includes(`/category/${cat.id}`);
return (
{/* 1차 카테고리 */}
{isActive ? : }
{cat.name}
{cat.children && cat.children.length > 0 && (
)}
{/* 2차 카테고리 (자식이 있을 경우) */}
{cat.children && cat.children.length > 0 && (
{cat.children.map((child) => {
const isChildActive = pathname.includes(`/category/${child.id}`);
return (
- {child.name}
);
})}
)}
);
})}