BlogList ๋ Œ๋”๋ง์„ Link ์ปดํฌ๋„ŒํŠธ๋กœ?

์ž‘์„ฑ์ผ : 10/17/2025

๋ธ”๋กœ๊ทธ ํŽ˜์ด์ง€์˜ ์ปดํฌ๋„ŒํŠธ ๊ตฌ์กฐ๋Š” ์ด๋ ‡๋‹ค. (๋ฐ์Šคํฌํƒ‘ ๊ธฐ์ค€)

ํŽ˜์ด์ง€
- ์นดํ…Œ๊ณ ๋ฆฌ ๋ชฉ๋ก CategoryTree
  - CategoryItem (์žฌ๊ท€)
- ๋ธ”๋กœ๊ทธ ๋ชฉ๋ก BlogList
  - BlogItem
// CategoryTree
<div className="flex flex-col w-4/12 p-2 border border-gray-200">
      {categories.map((category, i) => (
        <CategoryItem
          key={`c${i}`}
          category={category}
          selectedCategory={selectedCategory}
          level={1}
        />
      ))}
</div>

// CategoryItem
<div className="flex flex-col mx-1 border border-gray-300 py-1 rounded-xl my-1">
      <div className="flex items-center justify-between">
        <Link
          href={isSelected ? "/blog" : `/blog?category=${categoryPath}`}
          className={`
            flex-1
            rounded-xl
            hover:pl-4 transition-all
            cursor-pointer 
            py-1 pl-3
            `}
        >
          <span className={`${isSelected ? "font-bold underline" : ""}`}>
            {category.name}
          </span>
          <span className="ml-1 rounded text-xs text-gray-700">
            {category.blogs.length > 0 ? `(${category.blogs.length})` : ""}
          </span>
        </Link>

        {hasChildren && (
          <button
            onClick={() => setShowChildren(!showChildren)}
            className="px-2 text-gray-500 hover:text-gray-700"
          >
            {showChildren ? "โˆ’" : "+"}
          </button>
        )}
      </div>
      {showChildren &&
        category.children?.map((child) => (
          <CategoryItem
            key={`c${child.name}`}
            category={child}
            selectedCategory={selectedCategory}
            level={level + 1}
          />
        ))}
    </div>