commit bade790b86e130cc593ffbe40addcebfaf616a33 from: Omar Polo date: Thu Nov 05 14:39:06 2020 UTC generate a RSS feed also for Gemini commit - 61fdac08e848d1cf90bb239f4595fe002fd196ff commit + bade790b86e130cc593ffbe40addcebfaf616a33 blob - 16d2d1780f77335504d7ecc7d8564536216c316d blob + 754c106924546aeb9896ce7c3c8c277e30cb980f --- src/blog/core.clj +++ src/blog/core.clj @@ -123,8 +123,13 @@ (viewfn tag posts))) (defn render-rss [] + (spit (str "resources/out/gemini/rss.xml") + (rss/feed #(str "gemini://gemini.omarpolo.com/post/" % ".gmi") + (->> @posts + (filter gemini-post) + (map #(dissoc % :body))))) (spit (str "resources/out/http/rss.xml") - (rss/feed @posts))) + (rss/feed #(str "https://www.omarpolo.com/post/" % ".html") @posts))) (defn copy-dir "Copy the content of resources/`dir` to resources/out/`proto`/`dir`, assuming blob - 149e9941dc934d8db0a7ff5aeef4675ba1d9475f blob + d9fbb35f1099a3fb2319930bf6083a6339ff4b50 --- src/blog/rss.clj +++ src/blog/rss.clj @@ -6,21 +6,22 @@ [commonmark-hiccup.core :refer [markdown->hiccup default-config]] [hiccup.core :as hiccup])) -(defn item [{:keys [title date slug tags short body gemtext?]}] - (let [link (str "https://www.omarpolo.com/post/" slug ".html")] +(defn item [linkfn {:keys [title date slug tags short body gemtext?]}] + (let [link (linkfn slug)] [:item [:title title] - [:description - [:-cdata - (hiccup/html - (if gemtext? - (-> body gemtext/parse gemtext/to-hiccup) - (markdown->hiccup default-config body)))]] + (when body + [:description + [:-cdata + (hiccup/html + (if gemtext? + (-> body gemtext/parse gemtext/to-hiccup) + (markdown->hiccup default-config body)))]]) [:guid link] [:link link] [:pubDate (time/fmt-rfc-2822 date)]])) -(defn feed [posts] +(defn feed [linkfn posts] (indent-str (sexp-as-element [:rss {:version "2.0" :xmlns:atom "http://www.w3.org/2005/Atom"} @@ -30,4 +31,5 @@ [: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)]]))) + (map (partial item linkfn) + posts)]])))