Blob


1 (ns blog.rss
2 (:require [blog.time :as time]
3 [clojure.data.xml :refer :all]
4 [hiccup.core :as hiccup]
5 [commonmark-hiccup.core :refer [markdown->hiccup default-config]]))
7 (defn item [{:keys [title date slug tags short body]}]
8 (let [link (str "https://www.omarpolo.com/post/" slug ".html")]
9 [:item
10 [:title title]
11 [:description
12 [:-cdata
13 (hiccup/html
14 (markdown->hiccup default-config body))]]
15 [:guid link]
16 [:link link]
17 [:pubDate (time/fmt-rfc-2822 date)]]))
19 (defn feed [posts]
20 (indent-str
21 (sexp-as-element
22 [:rss {:version "2.0" :xmlns:atom "http://www.w3.org/2005/Atom"}
23 [:channel
24 [:title "yumh"]
25 [:description "Writing about things, sometimes"]
26 [:link "https://www.omarpolo.com"]
27 ;; fails to validate?
28 ;; [:atom:link {:href "https://www.omarpolo.com/rss.xml" :ref "self" :type "application/rss+xml"} nil]
29 (map item posts)]])))