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