summaryrefslogtreecommitdiff
path: root/src/utils/micro.ts
diff options
context:
space:
mode:
authorDawid Rycerz <dawid@rycerz.xyz>2025-07-03 13:46:07 +0300
committerDawid Rycerz <dawid@rycerz.xyz>2025-07-03 13:46:07 +0300
commitf100d259d2ffebe61fef56ea3964f6d534d598c8 (patch)
tree09d06511506da9c35585740d56598eb542fac079 /src/utils/micro.ts
parent1e5f5a953588cefa75396454c9aed0a79552db14 (diff)
Initial pleroma pull support
Diffstat (limited to 'src/utils/micro.ts')
-rw-r--r--src/utils/micro.ts26
1 files changed, 26 insertions, 0 deletions
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<MicroEntry[]> {
+ 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);
+ }
+}