import type { CollectionEntry } from "astro:content"; export type MicroEntry = CollectionEntry<"note">; export function sortMicroEntries(entries: MicroEntry[]): MicroEntry[] { return entries.sort((a, b) => b.data.publishDate.getTime() - a.data.publishDate.getTime()); } export async function getAllMicroPosts(): Promise { const { getCollection } = await import("astro:content"); const notes = await getCollection("note"); // Try to get micro posts if available, otherwise just use notes try { const microPosts = await getCollection("micro"); const allMicroPosts: (CollectionEntry<"note"> | CollectionEntry<"micro">)[] = [ ...notes, ...microPosts, ]; return sortMicroEntries(allMicroPosts as MicroEntry[]); } catch (error) { console.warn("Micro collection not available, using notes only:", error); return sortMicroEntries(notes); } }