feat: full site build — Project/Melody schema (Option A), admin CRUD, public sections, uploads, email+SMTP, internal analytics, legal pages, docs
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import type { ProjectType } from "@prisma/client";
|
||||
import { prisma } from "@/lib/db";
|
||||
|
||||
export async function getPublishedProjects(type: ProjectType, categorySlug?: string) {
|
||||
return prisma.project.findMany({
|
||||
where: {
|
||||
type,
|
||||
status: "PUBLISHED",
|
||||
category: categorySlug ? { slug: categorySlug, kind: "PROJECT" } : undefined,
|
||||
},
|
||||
orderBy: [{ isFeatured: "desc" }, { sortOrder: "asc" }, { publishedAt: "desc" }, { titleEn: "asc" }],
|
||||
include: {
|
||||
category: { select: { slug: true, nameAr: true, nameEn: true } },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getProjectCategories() {
|
||||
return prisma.category.findMany({
|
||||
where: { kind: "PROJECT" },
|
||||
orderBy: [{ order: "asc" }, { nameEn: "asc" }],
|
||||
select: {
|
||||
id: true,
|
||||
slug: true,
|
||||
nameAr: true,
|
||||
nameEn: true,
|
||||
_count: { select: { projects: true } },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getPublishedProject(type: ProjectType, slug: string) {
|
||||
return prisma.project.findFirst({
|
||||
where: { type, slug, status: "PUBLISHED" },
|
||||
include: {
|
||||
category: { select: { slug: true, nameAr: true, nameEn: true } },
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user