feat(glossaire): extend taxonomy and align Astro 6 content config
This commit is contained in:
@@ -3,15 +3,21 @@ import { getCollection } from "astro:content";
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
const slugOf = (entry: { id: string }) => String(entry.id).replace(/\.(md|mdx)$/i, "");
|
||||
|
||||
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}/`,
|
||||
}));
|
||||
|
||||
const index = entries.map((e) => {
|
||||
const slug = slugOf(e);
|
||||
return {
|
||||
slug,
|
||||
term: e.data.term,
|
||||
aliases: e.data.aliases ?? [],
|
||||
definitionShort: e.data.definitionShort,
|
||||
href: `/glossaire/${slug}/`,
|
||||
};
|
||||
});
|
||||
|
||||
return new Response(JSON.stringify(index), {
|
||||
headers: {
|
||||
@@ -19,4 +25,4 @@ export const GET: APIRoute = async () => {
|
||||
"Cache-Control": "public, max-age=3600",
|
||||
},
|
||||
});
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user