File size: 577 Bytes
ee23801 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import { CollectionEntry, getCollection } from "astro:content";
export async function getAllGuides(): Promise<Record<string, CollectionEntry<"guides">[]>> {
const allGuides: CollectionEntry<"guides">[] = await getCollection("guides");
const sortedGuides = allGuides.sort((a, b) => a.data.sort - b.data.sort);
return sortedGuides.reduce((acc: Record<string, CollectionEntry<"guides">[]>, curr: CollectionEntry<"guides">) => {
const { groupTitle } = curr.data;
acc[groupTitle] = acc[groupTitle] || [];
acc[groupTitle].push(curr);
return acc;
}, {});
}
|