summaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
authorDawid Rycerz <dawid@rycerz.xyz>2026-01-12 18:21:12 +0100
committerDawid Rycerz <dawid@rycerz.xyz>2026-01-12 19:11:50 +0100
commit51aa63873681216026d518cde4abeca307818a4b (patch)
treed57b19a6ed8ce2b7303191a668de6ed7f878e7a8 /src/pages
parent4ed3a82a8b8f111bed88559bf8d601bb7d947df9 (diff)
Add infinite posts downloads
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/micro/[...page].astro6
-rw-r--r--src/pages/micro/rss.xml.ts38
-rw-r--r--src/pages/rss.xml.ts6
3 files changed, 36 insertions, 14 deletions
diff --git a/src/pages/micro/[...page].astro b/src/pages/micro/[...page].astro
index 93a35de..edfecab 100644
--- a/src/pages/micro/[...page].astro
+++ b/src/pages/micro/[...page].astro
@@ -51,11 +51,7 @@ const paginationProps = {
<PageLayout meta={meta}>
<section>
<h1 class="title mb-6 flex items-center gap-3">
- Micro <a
- class="text-accent"
- href="https://social.craftknight.com/users/dawid.rss"
- target="_blank"
- >
+ Micro <a class="text-accent" href="/micro/rss.xml" target="_blank">
<span class="sr-only">RSS feed</span>
<Icon aria-hidden="true" class="h-6 w-6" focusable="false" name="mdi:rss" />
</a>
diff --git a/src/pages/micro/rss.xml.ts b/src/pages/micro/rss.xml.ts
index ce25129..1fd6f53 100644
--- a/src/pages/micro/rss.xml.ts
+++ b/src/pages/micro/rss.xml.ts
@@ -1,8 +1,9 @@
import { getCollection } from "astro:content";
import rss from "@astrojs/rss";
+import type { APIContext } from "astro";
import { siteConfig } from "@/site.config";
-export const GET = async () => {
+export const GET = async (context: APIContext) => {
// Get only Pleroma posts
const allMicro = await getCollection("micro").catch(() => []); // Fallback to empty array if micro collection fails
@@ -11,15 +12,38 @@ export const GET = async () => {
(a, b) => b.data.publishDate.getTime() - a.data.publishDate.getTime(),
);
- return rss({
- title: siteConfig.title,
- description: siteConfig.description,
- site: import.meta.env.SITE,
- items: allMicroPosts.map((post) => ({
+ // 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: { url: string; type: string }) =>
+ `<p><img src="${att.url}" alt="Attachment" style="max-width: 100%; height: auto;" /></p>`,
+ )
+ .join("");
+ fullContent += imagesHtml;
+ }
+
+ return {
title: post.data.title,
pubDate: post.data.publishDate,
link: `micro/${post.id}/`,
description: post.data.description,
- })),
+ content: fullContent,
+ };
+ });
+
+ 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" />`,
});
};
diff --git a/src/pages/rss.xml.ts b/src/pages/rss.xml.ts
index 8a6525d..39f3964 100644
--- a/src/pages/rss.xml.ts
+++ b/src/pages/rss.xml.ts
@@ -1,19 +1,21 @@
import rss from "@astrojs/rss";
+import type { APIContext } from "astro";
import { getAllPosts } from "@/data/post";
import { siteConfig } from "@/site.config";
-export const GET = async () => {
+export const GET = async (context: APIContext) => {
const posts = await getAllPosts();
return rss({
title: siteConfig.title,
description: siteConfig.description,
- site: import.meta.env.SITE,
+ site: context.site || import.meta.env.SITE,
items: posts.map((post) => ({
title: post.data.title,
description: post.data.description,
pubDate: post.data.publishDate,
link: `posts/${post.id}/`,
})),
+ customData: `<atom:link href="${context.site}rss.xml" rel="self" type="application/rss+xml" xmlns:atom="http://www.w3.org/2005/Atom" />`,
});
};