locale upgrade

This commit is contained in:
2026-01-22 20:56:35 +01:00
parent 377631ee50
commit 37a1bc4e18
28 changed files with 2117 additions and 71 deletions

View File

@@ -32,14 +32,17 @@ export default async function ProjectsPage({
orderBy: { createdAt: "desc" },
include: {
translations: {
where: { locale },
select: { title: true, description: true },
select: { title: true, description: true, locale: true },
},
},
});
const localized = projects.map((p) => {
const tr = p.translations?.[0];
const trPreferred = p.translations?.find((t) => t.locale === locale && (t?.title || t?.description));
const trDefault = p.translations?.find(
(t) => t.locale === p.defaultLocale && (t?.title || t?.description),
);
const tr = trPreferred ?? trDefault;
const { translations: _translations, ...rest } = p;
return {
...rest,