summaryrefslogtreecommitdiff
path: root/website/src/pages/microlog/rss.xml.ts
blob: fa04b32ac22ca688bd5ffd4a40bfec9e62ab61cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import path from "node:path";
import rss from "@astrojs/rss";
import type { APIContext } from "astro";
import { getCollection } from "astro:content";
import { renderGemtextToHtml } from "../../renderGemtextToHtml";

export async function GET(context: APIContext) {
  // `site` is guaranteed to exist because we define it in our Astro config
  const site = context.site!;
  const posts = await getCollection("microlog");

  return rss({
    title: "Joe Carstairs’ microlog",
    description: "My private X feed I guess?",
    customData: `
			<image>/images/headshot.webp</image>
		  <language>en-GB</language>
		`,
    site: path.join(site.toString(), "microlog"),
    trailingSlash: false,
    items: posts.map((post) => ({
      link: `/microlog/${post.id}`,
      title: post.id,
      content: renderGemtextToHtml(post.body ?? ""),
      pubDate: new Date(post.id.replace(/\.[0-9]+$/g, "")),
      author: "Joe Carstairs",
    })),
  });
}