@@ -23,12 +23,44 @@ export default async function PostDetail({ params }: { params: any }) {
|
||||
const parsed = settingRow ? JSON.parse(settingRow.value as string) : {};
|
||||
const showBanner: boolean = parsed.showBanner ?? true;
|
||||
|
||||
// 현재 게시글이 속한 카테고리의 보드들을 서브카테고리로 구성
|
||||
let subItems:
|
||||
| { id: string; name: string; href: string }[]
|
||||
| undefined = undefined;
|
||||
if (post?.boardId) {
|
||||
const categories = await prisma.boardCategory.findMany({
|
||||
where: { status: "active" },
|
||||
orderBy: [{ sortOrder: "asc" }, { createdAt: "asc" }],
|
||||
include: {
|
||||
boards: {
|
||||
where: { status: "active" },
|
||||
orderBy: [{ sortOrder: "asc" }, { createdAt: "asc" }],
|
||||
select: { id: true, name: true, slug: true },
|
||||
},
|
||||
},
|
||||
});
|
||||
const categoryOfPost = categories.find((c) =>
|
||||
c.boards.some((b) => b.id === post.boardId)
|
||||
);
|
||||
if (categoryOfPost) {
|
||||
subItems = categoryOfPost.boards.map((b) => ({
|
||||
id: b.id,
|
||||
name: b.name,
|
||||
href: `/boards/${b.slug}`,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* 상단 배너 */}
|
||||
{showBanner && (
|
||||
<section>
|
||||
<HeroBanner />
|
||||
<HeroBanner
|
||||
subItems={subItems}
|
||||
activeSubId={post?.boardId}
|
||||
showPartnerCats={false}
|
||||
/>
|
||||
</section>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user