commit - 0d4e99b2370cef0bcd500797be8dbb311ffa59c0
commit + a803b55b1683cbd77c7cd0e1605af069b4164bd9
blob - c20dbcd971d7ccfbba6def2611e03501ffaec7c4
blob + 8f63bd2d6ce044fb73997c7e5b73efa685e87a33
--- build.boot
+++ build.boot
:resource-paths #{"src" "resources"}
:dependencies '[[hiccup "1.0.5"]
[ring "1.8.0"]
- [commonmark-hiccup "0.1.0"]])
+ [commonmark-hiccup "0.1.0"]
+ [org.clojure/data.xml "0.2.0-alpha6"]])
(task-options!
pom {:project 'blog
blob - /dev/null
blob + 180422ed56ce7cc1c5839f871fdb8d7c79a9451f (mode 644)
--- /dev/null
+++ src/blog/rss.clj
+(ns blog.rss
+ (:require [blog.time :as time]
+ [clojure.data.xml :refer :all]
+ [hiccup.core :as hiccup]
+ [commonmark-hiccup.core :refer [markdown->hiccup default-config]]))
+
+(defn item [{:keys [title date slug tags short body]}]
+ (let [link (str "https://www.omarpolo.com/post/" slug ".html")]
+ [:item
+ [:title title]
+ [:description
+ [:-cdata
+ (hiccup/html
+ (markdown->hiccup default-config body))]]
+ [:guid link]
+ [:link link]
+ [:pubDate (time/fmt-rfc-2822 date)]]))
+
+(defn feed [posts]
+ (indent-str
+ (sexp-as-element
+ [:rss {:version "2.0" :xmlns:atom "http://www.w3.org/2005/Atom"}
+ [:channel
+ [:title "yumh"]
+ [:description "Writing about things, sometimes"]
+ [:link "https://www.omarpolo.com"]
+ ;; fails to validate?
+ ;; [:atom:link {:href "https://www.omarpolo.com/rss.xml" :ref "self" :type "application/rss+xml"} nil]
+ (map item posts)]])))