diff --git a/src/app/api/posts/route.ts b/src/app/api/posts/route.ts index 7c49915..715351d 100644 --- a/src/app/api/posts/route.ts +++ b/src/app/api/posts/route.ts @@ -100,6 +100,7 @@ export async function GET(req: Request) { isPinned: true, status: true, stat: { select: { recommendCount: true, views: true, commentsCount: true } }, + postTags: { select: { tag: { select: { name: true, slug: true } } } }, }, }), ]); diff --git a/src/app/api/tags/route.ts b/src/app/api/tags/route.ts new file mode 100644 index 0000000..59b05a2 --- /dev/null +++ b/src/app/api/tags/route.ts @@ -0,0 +1,13 @@ +import { NextResponse } from "next/server"; +import prisma from "@/lib/prisma"; + +export async function GET() { + const tags = await prisma.tag.findMany({ + orderBy: { name: "asc" }, + take: 100, + select: { slug: true, name: true }, + }); + return NextResponse.json({ tags }); +} + + diff --git a/src/app/components/PostList.tsx b/src/app/components/PostList.tsx index 73281b0..ee7390b 100644 --- a/src/app/components/PostList.tsx +++ b/src/app/components/PostList.tsx @@ -8,6 +8,7 @@ type Item = { isPinned: boolean; status: string; stat?: { recommendCount: number; views: number; commentsCount: number } | null; + postTags?: { tag: { name: string; slug: string } }[]; }; type Resp = { @@ -65,6 +66,13 @@ export function PostList({ boardId, sort = "recent", q, tag, author, start, end