7.8 일반 게시판 공용 폼/라우트 템플릿 생성 o
This commit is contained in:
16
src/app/boards/[id]/page.tsx
Normal file
16
src/app/boards/[id]/page.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
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";
|
||||
return (
|
||||
<div>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
|
||||
<h1>게시판</h1>
|
||||
<a href={`/posts/new?boardId=${params.id}`}><button>새 글</button></a>
|
||||
</div>
|
||||
<PostList boardId={params.id} sort={sort} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
16
src/app/boards/page.tsx
Normal file
16
src/app/boards/page.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
export default async function BoardsPage() {
|
||||
const res = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL ?? ""}/api/boards`, { cache: "no-store" });
|
||||
const { boards } = await res.json();
|
||||
return (
|
||||
<div>
|
||||
<h1>게시판</h1>
|
||||
<ul style={{ display: "flex", flexDirection: "column", gap: 6 }}>
|
||||
{boards?.map((b: any) => (
|
||||
<li key={b.id}><a href={`/boards/${b.id}`}>{b.name}</a></li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user