23 lines
598 B
TypeScript
23 lines
598 B
TypeScript
import type { APIRoute } from "astro";
|
|
import { getCollection } from "astro:content";
|
|
|
|
export const prerender = true;
|
|
|
|
export const GET: APIRoute = async () => {
|
|
const entries = await getCollection("glossaire");
|
|
const index = entries.map((e) => ({
|
|
slug: e.slug,
|
|
term: e.data.term,
|
|
aliases: e.data.aliases ?? [],
|
|
definitionShort: e.data.definitionShort,
|
|
href: `/glossaire/${e.slug}/`,
|
|
}));
|
|
|
|
return new Response(JSON.stringify(index), {
|
|
headers: {
|
|
"Content-Type": "application/json; charset=utf-8",
|
|
"Cache-Control": "public, max-age=3600",
|
|
},
|
|
});
|
|
};
|