Files
pasargad/src/app/api/projects/[id]/route.ts
T

29 lines
740 B
TypeScript
Raw Normal View History

import { NextResponse } from 'next/server';
import { cookies } from 'next/headers';
import { projects } from '../data';
export async function GET(request: Request, context: any) {
const params = await context.params;
const projectId = params.id;
const cookieStore = await cookies();
const lang = cookieStore.get('locale')?.value || 'en';
let project = projects.find((project) => project.id === projectId);
if (!project) {
return NextResponse.json({ error: 'Not found' }, { status: 404 });
}
if (lang === 'fa') {
project = {
...project,
title: project.fa_title || project.title,
content: project.fa_content || project.content,
};
}
return NextResponse.json({
data: project,
});
}