2025-10-09 17:11:50 +09:00
|
|
|
import { PostList } from "@/app/components/PostList";
|
2025-10-10 14:39:22 +09:00
|
|
|
import { headers } from "next/headers";
|
2025-10-09 17:11:50 +09:00
|
|
|
|
2025-10-10 14:46:59 +09:00
|
|
|
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 sort = (sp?.sort as "recent" | "popular" | undefined) ?? "recent";
|
2025-10-09 18:14:22 +09:00
|
|
|
// 보드 slug 조회 (새 글 페이지 프리셋 전달)
|
2025-10-10 14:39:22 +09:00
|
|
|
const h = await headers();
|
|
|
|
|
const host = h.get("host") ?? "localhost:3000";
|
|
|
|
|
const proto = h.get("x-forwarded-proto") ?? "http";
|
|
|
|
|
const base = process.env.NEXT_PUBLIC_BASE_URL || `${proto}://${host}`;
|
|
|
|
|
const res = await fetch(new URL("/api/boards", base).toString(), { cache: "no-store" });
|
2025-10-09 18:14:22 +09:00
|
|
|
const { boards } = await res.json();
|
2025-10-10 14:39:22 +09:00
|
|
|
const board = (boards || []).find((b: any) => b.id === id);
|
2025-10-09 17:11:50 +09:00
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
|
|
|
|
|
<h1>게시판</h1>
|
2025-10-10 14:39:22 +09:00
|
|
|
<a href={`/posts/new?boardId=${id}${board?.slug ? `&boardSlug=${board.slug}` : ""}`}><button>새 글</button></a>
|
2025-10-09 17:11:50 +09:00
|
|
|
</div>
|
2025-10-10 14:39:22 +09:00
|
|
|
<PostList boardId={id} sort={sort} />
|
2025-10-09 17:11:50 +09:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|