aboutsummaryrefslogtreecommitdiff
path: root/feed.typ
diff options
context:
space:
mode:
Diffstat (limited to 'feed.typ')
-rw-r--r--feed.typ47
1 files changed, 3 insertions, 44 deletions
diff --git a/feed.typ b/feed.typ
index 3a5fd21..a72a536 100644
--- a/feed.typ
+++ b/feed.typ
@@ -1,19 +1,11 @@
-// RSS 2.0 and Atom feeds for the blog posts, emitted as feed.xml and
-// atom.xml by main.typ. Entries are built from the metadata in
-// site-info.pages (newest first).
+// Atom (RFC 4287) feed for the blog posts, emitted as atom.xml by
+// main.typ. Entries are built from the metadata in site-info.pages
+// (newest first).
#import "/global/common.typ": baseurl
#let xml-escape(s) = s.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
-// ISO date ("2026-07-28") to RFC 822 ("Tue, 28 Jul 2026 00:00:00 GMT").
-#let rfc822(iso) = {
- let (y, m, d) = iso.split("-").map(int)
- datetime(year: y, month: m, day: d).display(
- "[weekday repr:short], [day] [month repr:short] [year] 00:00:00 GMT"
- )
-}
-
// ISO date ("2026-07-28") to RFC 3339 ("2026-07-28T00:00:00Z").
#let rfc3339(iso) = iso + "T00:00:00Z"
@@ -31,39 +23,6 @@
entries
}
-#let feed-xml(site-info) = {
- let items = _entries(site-info, (title, url, p) => {
- let lines = (
- " <item>",
- " <title>" + xml-escape(title) + "</title>",
- " <link>" + url + "</link>",
- " <guid>" + url + "</guid>",
- )
- if "date" in p {
- lines.push(" <pubDate>" + rfc822(p.date) + "</pubDate>")
- }
- if "description" in p {
- lines.push(" <description>" + xml-escape(p.description) + "</description>")
- }
- lines.push(" </item>")
- lines.join("\n")
- })
-
- (
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
- "<rss version=\"2.0\">",
- "<channel>",
- " <title>" + xml-escape(site-info.title) + "</title>",
- " <link>" + baseurl + "/</link>",
- " <description>Posts from " + xml-escape(site-info.title) + " (" + baseurl + ")</description>",
- items.join("\n"),
- "</channel>",
- "</rss>",
- "",
- ).join("\n")
-}
-
-// Atom (RFC 4287) feed, emitted as atom.xml by main.typ.
#let atom-xml(site-info) = {
let entries = _entries(site-info, (title, url, p) => {
let lines = (