Refactor for i18n, CMS integration, and project slugs; enhance admin & analytics
Co-authored-by: dennis <dennis@konkol.net>
This commit is contained in:
21
app/[locale]/layout.tsx
Normal file
21
app/[locale]/layout.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import { NextIntlClientProvider } from "next-intl";
|
||||
import { getMessages } from "next-intl/server";
|
||||
import React from "react";
|
||||
|
||||
export default async function LocaleLayout({
|
||||
children,
|
||||
params,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
params: Promise<{ locale: string }>;
|
||||
}) {
|
||||
const { locale } = await params;
|
||||
const messages = await getMessages({ locale });
|
||||
|
||||
return (
|
||||
<NextIntlClientProvider locale={locale} messages={messages}>
|
||||
{children}
|
||||
</NextIntlClientProvider>
|
||||
);
|
||||
}
|
||||
|
||||
2
app/[locale]/legal-notice/page.tsx
Normal file
2
app/[locale]/legal-notice/page.tsx
Normal file
@@ -0,0 +1,2 @@
|
||||
export { default } from "../../legal-notice/page";
|
||||
|
||||
2
app/[locale]/page.tsx
Normal file
2
app/[locale]/page.tsx
Normal file
@@ -0,0 +1,2 @@
|
||||
export { default } from "../_ui/HomePage";
|
||||
|
||||
2
app/[locale]/privacy-policy/page.tsx
Normal file
2
app/[locale]/privacy-policy/page.tsx
Normal file
@@ -0,0 +1,2 @@
|
||||
export { default } from "../../privacy-policy/page";
|
||||
|
||||
36
app/[locale]/projects/[slug]/page.tsx
Normal file
36
app/[locale]/projects/[slug]/page.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import ProjectDetailClient from "@/app/_ui/ProjectDetailClient";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
export const revalidate = 300;
|
||||
|
||||
export default async function ProjectPage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ locale: string; slug: string }>;
|
||||
}) {
|
||||
const { locale, slug } = await params;
|
||||
|
||||
const project = await prisma.project.findFirst({
|
||||
where: { slug, published: true },
|
||||
include: {
|
||||
translations: {
|
||||
where: { locale },
|
||||
select: { title: true, description: true },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!project) return notFound();
|
||||
|
||||
const tr = project.translations?.[0];
|
||||
const { translations: _translations, ...rest } = project;
|
||||
const localized = {
|
||||
...rest,
|
||||
title: tr?.title ?? project.title,
|
||||
description: tr?.description ?? project.description,
|
||||
};
|
||||
|
||||
return <ProjectDetailClient project={localized} locale={locale} />;
|
||||
}
|
||||
|
||||
36
app/[locale]/projects/page.tsx
Normal file
36
app/[locale]/projects/page.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
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} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user