RSS feeds
@scribe-atp/core exports generateFeed — a function that takes a fetched Site and returns a complete RSS 2.0 XML string. You wire it into your server-side route handler and return it as a response.
Basic usage
Section titled “Basic usage”generateFeed needs a baseUrl (your site’s origin) and a feedUrl (the canonical URL of the feed itself):
import { fetchSite, generateFeed } from '@scribe-atp/core';
const site = await fetchSite('alice.bsky.social', 'alice-bsky-social');const xml = generateFeed(site, { baseUrl: 'https://alice.example.com', feedUrl: 'https://alice.example.com/feed.xml',});generateFeed returns a string of RSS 2.0 XML ready to serve directly.
Wiring into your framework
Section titled “Wiring into your framework”import { fetchSite, generateFeed } from '@scribe-atp/core';
export async function loader({ request }: { request: Request }) { const origin = new URL(request.url).origin; const site = await fetchSite('alice.bsky.social', 'alice-bsky-social', request.signal); const xml = generateFeed(site, { baseUrl: origin, feedUrl: `${origin}/feed.xml`, }); return new Response(xml, { headers: { 'Content-Type': 'application/rss+xml; charset=utf-8' }, });}import { fetchSite, generateFeed } from '@scribe-atp/core';
export async function GET(request: Request) { const origin = new URL(request.url).origin; const site = await fetchSite('alice.bsky.social', 'alice-bsky-social', request.signal); const xml = generateFeed(site, { baseUrl: origin, feedUrl: `${origin}/feed.xml`, }); return new Response(xml, { headers: { 'Content-Type': 'application/rss+xml; charset=utf-8' }, });}import { fetchSite, generateFeed } from '@scribe-atp/core';import type { RequestHandler } from './$types';
export const GET: RequestHandler = async ({ url }) => { const site = await fetchSite('alice.bsky.social', 'alice-bsky-social'); const xml = generateFeed(site, { baseUrl: url.origin, feedUrl: `${url.origin}/feed.xml`, }); return new Response(xml, { headers: { 'Content-Type': 'application/rss+xml; charset=utf-8' }, });};What gets included
Section titled “What gets included”generateFeed includes only published articles — articles in groups. Unpublished articles (site.ungroupedArticles) are excluded.
Each feed item contains:
<title>— fromarticle.title<description>— fromarticle.synopsis(when set)<link>— the canonical article URL, built from the site’surlandurlPrefix<pubDate>— fromarticle.createdAt<guid>— the article’s AT URI (stable across URL changes)
Feed auto-discovery
Section titled “Feed auto-discovery”Add a <link> tag in your HTML <head> so feed readers can discover the feed automatically:
<link rel="alternate" type="application/rss+xml" title="My Blog" href="/feed.xml"/>