From 5b8749d11f779b85097d165452dd7b09e8af8879 Mon Sep 17 00:00:00 2001 From: koreacomp5 Date: Wed, 5 Nov 2025 22:27:29 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A9=94=EC=9D=B8=EC=8A=A4=ED=83=80=EC=9D=BC,?= =?UTF-8?q?=20=ED=98=B8=EB=B2=84=20=EB=93=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/components/BoardPanelClient.tsx | 12 +++--- src/app/components/PostList.tsx | 14 ++++--- src/app/page.tsx | 52 +++++++++++++++++-------- 3 files changed, 50 insertions(+), 28 deletions(-) diff --git a/src/app/components/BoardPanelClient.tsx b/src/app/components/BoardPanelClient.tsx index 28b5bf5..8dfc6f3 100644 --- a/src/app/components/BoardPanelClient.tsx +++ b/src/app/components/BoardPanelClient.tsx @@ -218,7 +218,7 @@ export function BoardPanelClient({ // attachments에서 이미지를 먼저 찾고, 없으면 content에서 추출 const firstImage = post.attachments?.[0]?.url || extractImageFromContent(post.content); return ( - +
{firstImage ? ( )}
- {stripHtml(post.title)} + {stripHtml(post.title)} {(post.stat?.commentsCount ?? 0) > 0 && ( [{post.stat?.commentsCount}] )} @@ -314,9 +314,9 @@ export function BoardPanelClient({
) : ( - + )} diff --git a/src/app/components/PostList.tsx b/src/app/components/PostList.tsx index e67c19d..819df63 100644 --- a/src/app/components/PostList.tsx +++ b/src/app/components/PostList.tsx @@ -35,7 +35,7 @@ function stripHtml(html: string | null | undefined): string { return html.replace(/<[^>]*>/g, "").trim(); } -export function PostList({ boardId, sort = "recent", q, tag, author, authorId, start, end, variant = "default", newPostHref }: { boardId?: string; sort?: "recent" | "popular"; q?: string; tag?: string; author?: string; authorId?: string; start?: string; end?: string; variant?: "default" | "board"; newPostHref?: string }) { +export function PostList({ boardId, sort = "recent", q, tag, author, authorId, start, end, variant = "default", newPostHref, titleHoverOrange, pageSizeOverride, compact }: { boardId?: string; sort?: "recent" | "popular"; q?: string; tag?: string; author?: string; authorId?: string; start?: string; end?: string; variant?: "default" | "board"; newPostHref?: string; titleHoverOrange?: boolean; pageSizeOverride?: number; compact?: boolean }) { const sp = useSearchParams(); const listContainerRef = useRef(null); const [lockedMinHeight, setLockedMinHeight] = useState(null); @@ -43,7 +43,9 @@ export function PostList({ boardId, sort = "recent", q, tag, author, authorId, s // board 변형에서는 URL에서 pageSize를 읽고, 기본값은 20 const defaultPageSize = variant === "board" ? 20 : 10; const pageSizeParam = sp.get("pageSize"); - const pageSize = pageSizeParam ? Math.min(50, Math.max(10, parseInt(pageSizeParam, 10))) : defaultPageSize; + const pageSize = (variant === "board" && pageSizeOverride) + ? pageSizeOverride + : (pageSizeParam ? Math.min(50, Math.max(10, parseInt(pageSizeParam, 10))) : defaultPageSize); // board 변형: 번호 페이지네이션 const initialPage = useMemo(() => Math.max(1, parseInt(sp.get("page") || "1", 10)), [sp]); @@ -168,15 +170,17 @@ export function PostList({ boardId, sort = "recent", q, tag, author, authorId, s
    {items.map((p) => ( -
  • +
  • {/* bullet/공지 아이콘 자리 */}
    {p.isPinned ? "★" : "•"}
    - + {p.isPinned && 공지} - {stripHtml(p.title)} + + {stripHtml(p.title)} + {(p.stat?.commentsCount ?? 0) > 0 && ( [{p.stat?.commentsCount}] )} diff --git a/src/app/page.tsx b/src/app/page.tsx index 936fc34..4d28042 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -57,6 +57,14 @@ export default async function Home({ searchParams }: { searchParams: Promise<{ s if (admin) currentUser = admin; } + // 내가 쓴 게시글/댓글 수 + let myPostsCount = 0; + let myCommentsCount = 0; + if (currentUser) { + myPostsCount = await prisma.post.count({ where: { authorId: currentUser.userId, status: "published" } }); + myCommentsCount = await prisma.comment.count({ where: { authorId: currentUser.userId } }); + } + // 메인페이지 설정 불러오기 const SETTINGS_KEY = "mainpage_settings" as const; const settingRow = await prisma.setting.findUnique({ where: { key: SETTINGS_KEY } }); @@ -164,7 +172,7 @@ export default async function Home({ searchParams }: { searchParams: Promise<{ s where: { boardId: sb.id, status: "published" }, select: { id: true, title: true, createdAt: true, stat: { select: { recommendCount: true, commentsCount: true } } }, orderBy: { createdAt: "desc" }, - take: 7, + take: 16, }); } // 기본 타입은 PostList가 자체적으로 API를 호출하므로 데이터 미리 가져오지 않음 @@ -270,28 +278,38 @@ export default async function Home({ searchParams }: { searchParams: Promise<{ s
    - - - - 내 정보 페이지 + + + + + 내 정보 페이지 + - - - - 포인트 히스토리 + + + + + 포인트 히스토리 + - - - - 내가 쓴 게시글 + + + + + 내가 쓴 게시글 + + {myPostsCount.toLocaleString()}개 - - - - 내가 쓴 댓글 + + + + + 내가 쓴 댓글 + + {myCommentsCount.toLocaleString()}개