Files
blog/src/pages/api/posts.json.js
T
2026-06-18 21:44:37 +08:00

15 lines
315 B
JavaScript

import { getAllPosts } from '@/lib/posts';
export async function GET() {
const posts = (await getAllPosts()).map((post) => ({
title: post.title,
href: post.href,
}));
return new Response(JSON.stringify(posts), {
headers: {
'content-type': 'application/json; charset=utf-8',
},
});
}