From f100d259d2ffebe61fef56ea3964f6d534d598c8 Mon Sep 17 00:00:00 2001 From: Dawid Rycerz Date: Thu, 3 Jul 2025 13:46:07 +0300 Subject: Initial pleroma pull support --- src/utils/micro.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/utils/micro.ts (limited to 'src/utils/micro.ts') diff --git a/src/utils/micro.ts b/src/utils/micro.ts new file mode 100644 index 0000000..7344850 --- /dev/null +++ b/src/utils/micro.ts @@ -0,0 +1,26 @@ +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); + } +} -- cgit v1.2.3