Leaflet Blog in Deno Fresh
1import rehypeFormat from "npm:rehype-format"; 2import rehypeStringify from "npm:rehype-stringify"; 3import remarkParse from "npm:remark-parse"; 4import remarkRehype from "npm:remark-rehype"; 5import RSS from "npm:rss"; 6import { unified } from "npm:unified"; 7 8import { getPosts } from "../lib/api.ts"; 9 10export const dynamic = "force-static"; 11export const revalidate = 3600; // 1 hour 12 13export async function GET() { 14 const posts = await getPosts(); 15 16 const rss = new RSS({ 17 title: "knotbin", 18 feed_url: "https://knotbin.xyz/rss", 19 site_url: "https://knotbin.xyz", 20 description: "a webbed site", 21 }); 22 23 for (const post of posts) { 24 rss.item({ 25 title: post.value.title ?? "Untitled", 26 description: await unified() 27 .use(remarkParse) 28 .use(remarkRehype) 29 .use(rehypeFormat) 30 .use(rehypeStringify) 31 .process(post.value.content) 32 .then((v) => v.toString()), 33 url: `https://mozzius.dev/post/${post.uri.split("/").pop()}`, 34 date: new Date(post.value.createdAt ?? Date.now()), 35 }); 36 } 37 38 return new Response(rss.xml(), { 39 headers: { 40 "content-type": "application/rss+xml", 41 }, 42 }); 43}