api project

This commit is contained in:
zahravaziri
2025-06-10 17:30:21 +03:30
parent 3e9143f32c
commit ab37893d1b
11 changed files with 172 additions and 278 deletions
+41
View File
@@ -0,0 +1,41 @@
import { NextResponse } from 'next/server';
import { cookies } from 'next/headers';
import { projects } from './data';
export async function GET(request: Request) {
let data = projects;
const cookieStore = await cookies();
const lang = (await cookieStore).get('lang')?.value || 'fa';
if (lang === 'fa') {
data = projects.map(
({
id,
title,
fa_title,
imageSrc,
link,
}) => {
if (lang === 'fa') {
return {
id,
title: fa_title || title,
imageSrc,
link,
};
}
return {
id,
title,
imageSrc,
link,
};
},
);
}
return NextResponse.json({ data: projects });
}