api project
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
Reference in New Issue
Block a user