Files
pasargad/src/app/api/projects/route.ts
T

42 lines
785 B
TypeScript
Raw Normal View History

2025-06-10 17:30:21 +03:30
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 });
}