import { prisma } from "@/lib/prisma"; import { getServerSession } from "next-auth"; import { authOptions } from "@/lib/auth"; export const dynamic = "force-dynamic"; async function getHotTopics() { return prisma.forumTopic.findMany({ where: {}, include: { category: { select: { name: true, slug: true, icon: true } }, user: { select: { id: true, name: true, email: true, avatarUrl: true, level: true, points: true } }, _count: { select: { posts: true } }, }, orderBy: [{ isPinned: "desc" }, { createdAt: "desc" }], take: 5, }); } async function getActiveUsers() { return prisma.user.findMany({ where: { OR: [ { forumTopics: { some: {} } }, { forumPosts: { some: {} } }, ], }, select: { id: true, name: true, email: true, avatarUrl: true, level: true, points: true }, take: 5, }); } export default async function CommunityPage() { const categories = await prisma.forumCategory.findMany({ where: { parentId: null }, include: { children: { orderBy: [{ sortOrder: "asc" }], }, }, orderBy: [{ sortOrder: "asc" }, { createdAt: "desc" }], }); const [hotTopics, activeUsers] = await Promise.all([getHotTopics(), getActiveUsers()]); return (
AI爱好者交流社区
{child.description}
)}{user.name || user.email.split("@")[0]}
{user.points}分