yeas
This commit is contained in:
@@ -36,4 +36,23 @@ export async function POST(request: Request) {
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function PATCH(request: Request) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
const { pinned } = body; // expects an array of slugs
|
||||
if (!Array.isArray(pinned)) {
|
||||
return NextResponse.json({ error: 'Invalid pinned data' }, { status: 400 });
|
||||
}
|
||||
const pinnedPath = path.join(postsDirectory, 'pinned.json');
|
||||
fs.writeFileSync(pinnedPath, JSON.stringify(pinned, null, 2), 'utf8');
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error('Error updating pinned.json:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Error updating pinned.json' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user