driver.js / docs /src /lib /guide.ts
kamrify's picture
Make docs pages responsive
ee23801
raw
history blame contribute delete
577 Bytes
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;
}, {});
}