summaryrefslogtreecommitdiff
path: root/src/pages/micro/rss.xml.ts
diff options
context:
space:
mode:
authorDawid Rycerz <dawid@rycerz.xyz>2026-01-13 15:44:43 +0100
committerDawid Rycerz <dawid@rycerz.xyz>2026-01-13 15:44:43 +0100
commitc0dcecc43e36eeb6b10f662c1be760736cd0dbac (patch)
tree9c421dc980a3e011f0bb4671e90b0d8a38ef614d /src/pages/micro/rss.xml.ts
parent52411f6cb9efc10dd683096b34e5c279a11f7e0a (diff)
Cleanup old micro pages
Diffstat (limited to 'src/pages/micro/rss.xml.ts')
-rw-r--r--src/pages/micro/rss.xml.ts59
1 files changed, 0 insertions, 59 deletions
diff --git a/src/pages/micro/rss.xml.ts b/src/pages/micro/rss.xml.ts
deleted file mode 100644
index 9356341..0000000
--- a/src/pages/micro/rss.xml.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-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) =>
- `<p><img src="${att.url}" alt="${att.alt || "Image"}" style="max-width: 100%; height: auto;" /></p>`,
- )
- .join("");
- fullContent += imagesHtml;
- }
-
- // Build author customData for RSS
- let authorCustomData = "";
- if (post.data.author) {
- const authorName = post.data.author.displayName || post.data.author.username;
- authorCustomData = `<author>${authorName}</author><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">${authorName}</dc:creator>`;
- }
-
- return {
- title: post.data.title,
- pubDate: post.data.publishDate,
- link: `micro/${post.id}/`,
- description: post.data.description,
- content: fullContent,
- customData: authorCustomData,
- };
- });
-
- const site = context.site || import.meta.env.SITE;
-
- return rss({
- title: siteConfig.title,
- description: siteConfig.description,
- site,
- items,
- customData: `<atom:link href="${site}micro/rss.xml" rel="self" type="application/rss+xml" xmlns:atom="http://www.w3.org/2005/Atom" />`,
- });
-};