RSS feed
An /rss.xml endpoint from a content collection with @astrojs/rss.
Native .astro · no React · MIT · free, no account
Install
npx shadcn@latest add https://www.themes.dev/astro/r/rss-feed.jsonThe CLI needs a components.json (from npx shadcn init), which also writes the tokens these files use. It adds @astrojs/rss. No CLI? Copy the files below to the same paths.
Files
// The RSS feed at /rss.xml, from a content collection (here "posts" with title, summary and date, as the post model// has them). Needs @astrojs/rss and `site` in astro.config.mjs. Link it from your <head>:// <link rel="alternate" type="application/rss+xml" title="Blog" href="/rss.xml" />import rss from '@astrojs/rss';import type { APIContext } from 'astro';import { getCollection } from 'astro:content'; export async function GET(context: APIContext) { const posts = (await getCollection('posts')).sort((a, b) => +new Date(b.data.date) - +new Date(a.data.date)); return rss({ title: 'Blog', description: 'New posts, newest first.', site: context.site!, items: posts.map((p) => ({ title: p.data.title, description: p.data.summary, pubDate: new Date(p.data.date), link: `/blog/${p.id}/` })), });}More for site
- Theme toggleFreeA 36px button that switches light and dark and remembers the choice, plus the head script that prevents a flash.ThemeToggle.astro · ThemeScript.astro
- llms.txtFreeAn /llms.txt endpoint that lists your pages and posts for AI tools, built from your collections.llms.txt.ts
- robots.txtFreeA /robots.txt endpoint with your sitemap's address and the paths to keep out of search.robots.txt.ts