2025-10-09 17:11:50 +09:00
|
|
|
import { PostList } from "@/app/components/PostList";
|
|
|
|
|
|
|
|
|
|
export default async function BoardDetail({ params, searchParams }: { params: { id: string }; searchParams?: { sort?: "recent" | "popular" } }) {
|
|
|
|
|
const sort = searchParams?.sort ?? "recent";
|
2025-10-09 18:14:22 +09:00
|
|
|
// 보드 slug 조회 (새 글 페이지 프리셋 전달)
|
|
|
|
|
const res = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL ?? ""}/api/boards`, { cache: "no-store" });
|
|
|
|
|
const { boards } = await res.json();
|
|
|
|
|
const board = (boards || []).find((b: any) => b.id === params.id);
|
2025-10-09 17:11:50 +09:00
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
|
|
|
|
|
<h1>게시판</h1>
|
2025-10-09 18:14:22 +09:00
|
|
|
<a href={`/posts/new?boardId=${params.id}${board?.slug ? `&boardSlug=${board.slug}` : ""}`}><button>새 글</button></a>
|
2025-10-09 17:11:50 +09:00
|
|
|
</div>
|
|
|
|
|
<PostList boardId={params.id} sort={sort} />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|