import { getCollection } from "astro:content"; import rss from "@astrojs/rss"; import type { APIContext } from "astro"; import { siteConfig } from "@/site.config"; export const GET = async (context: APIContext) => { // Get only Pleroma posts tagged with "micro" const allMicro = await getCollection("micro", ({ data }) => data.tags?.includes("micro")).catch( () => [], ); // Fallback to empty array if micro collection fails // Sort all micro posts const allMicroPosts = allMicro.sort( (a, b) => b.data.publishDate.getTime() - a.data.publishDate.getTime(), ); // Generate RSS items with full content and images const items = allMicroPosts.map((post) => { // Get the pre-rendered HTML from the post let fullContent = post.rendered?.html || post.body || ""; // Append images if available if (post.data.attachments && post.data.attachments.length > 0) { const imagesHtml = post.data.attachments .map( (att) => `