This commit is contained in:
koreacomp5
2025-11-02 04:39:28 +09:00
parent d057ebef4a
commit 4d310346c1
15 changed files with 28 additions and 28 deletions

View File

@@ -7,7 +7,7 @@ import { headers } from "next/headers";
export default async function BoardDetail({ params, searchParams }: { params: any; searchParams: any }) {
const p = params?.then ? await params : params;
const sp = searchParams?.then ? await searchParams : searchParams;
const id = p.id as string;
const idOrSlug = p.id as string;
const sort = (sp?.sort as "recent" | "popular" | undefined) ?? "recent";
// 보드 slug 조회 (새 글 페이지 프리셋 전달)
const h = await headers();
@@ -16,7 +16,8 @@ export default async function BoardDetail({ params, searchParams }: { params: an
const base = process.env.NEXT_PUBLIC_BASE_URL || `${proto}://${host}`;
const res = await fetch(new URL("/api/boards", base).toString(), { cache: "no-store" });
const { boards } = await res.json();
const board = (boards || []).find((b: any) => b.id === id);
const board = (boards || []).find((b: any) => b.slug === idOrSlug || b.id === idOrSlug);
const id = board?.id as string;
const siblingBoards = (boards || []).filter((b: any) => b.category?.id && b.category.id === board?.category?.id);
const categoryName = board?.category?.name ?? "";
return (
@@ -24,14 +25,14 @@ export default async function BoardDetail({ params, searchParams }: { params: an
{/* 상단 배너 (서브카테고리 표시) */}
<section>
<HeroBanner
subItems={siblingBoards.map((b: any) => ({ id: b.id, name: b.name, href: `/boards/${b.id}` }))}
subItems={siblingBoards.map((b: any) => ({ id: b.id, name: b.name, href: `/boards/${b.slug}` }))}
activeSubId={id}
/>
</section>
{/* 검색/필터 툴바 + 리스트 */}
<section>
<BoardToolbar boardId={id} />
<BoardToolbar boardId={board?.slug} />
<div className="p-0">
<PostList
boardId={id}