37 lines
870 B
TypeScript
37 lines
870 B
TypeScript
import { prisma } from "@/lib/prisma";
|
|
import ProjectsPageClient from "@/app/_ui/ProjectsPageClient";
|
|
|
|
export const revalidate = 300;
|
|
|
|
export default async function ProjectsPage({
|
|
params,
|
|
}: {
|
|
params: Promise<{ locale: string }>;
|
|
}) {
|
|
const { locale } = await params;
|
|
|
|
const projects = await prisma.project.findMany({
|
|
where: { published: true },
|
|
orderBy: { createdAt: "desc" },
|
|
include: {
|
|
translations: {
|
|
where: { locale },
|
|
select: { title: true, description: true },
|
|
},
|
|
},
|
|
});
|
|
|
|
const localized = projects.map((p) => {
|
|
const tr = p.translations?.[0];
|
|
const { translations: _translations, ...rest } = p;
|
|
return {
|
|
...rest,
|
|
title: tr?.title ?? p.title,
|
|
description: tr?.description ?? p.description,
|
|
};
|
|
});
|
|
|
|
return <ProjectsPageClient projects={localized} locale={locale} />;
|
|
}
|
|
|