import type { APIRoute } from "astro"; import { getCollection } from "astro:content"; import type { CollectionEntry } from "astro:content"; export const GET: APIRoute = async (): Promise => { const allPosts: CollectionEntry<"post">[] = await getCollection("post"); const searchData = allPosts.map((post) => ({ id: post.id, title: post.data.title, description: post.data.description, body: post.body, })); return new Response(JSON.stringify(searchData), { status: 200, headers: { "Content-Type": "application/json", }, }); };