Skip to content

Commit

Permalink
Add pubDate to RSS items
Browse files Browse the repository at this point in the history
  • Loading branch information
S4G4R committed May 27, 2024
1 parent b166a54 commit 6f3d9fd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/com/sagar/casa/api/storyblok.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
(defn timestamp->date
"Converts an ISO timestamp to a date
eg. `2023-12-05T15:26:17.541216Z` -> `05/12/2023`"
eg. `2023-12-05T15:26:17.541216Z` -> `05 December, 2023`"
[timestamp]
(let [{:keys [year
month-of-year
Expand Down Expand Up @@ -70,7 +70,8 @@
[_ {:keys [id first-published-at full-slug]
{:keys [body title description]} :content}]
{:id id
:timestamp (timestamp->date first-published-at)
:date (timestamp->date first-published-at)
:first-published-at (jt/instant first-published-at)
:slug full-slug
:html-body (sb/richtext->html body)
:title title
Expand Down
6 changes: 5 additions & 1 deletion src/com/sagar/casa/rss.clj
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
(ns com.sagar.casa.rss
(:require [com.sagar.casa.api.storyblok :as api]
[clojure.set :refer [rename-keys]]
[clj-rss.core :as rss]))


(defn rss-feed
[]
(->> (api/get-story :blogs)
(map #(select-keys % [:title :slug :description]))
(map #(select-keys % [:id :title :slug :description
:first-published-at]))
(map #(assoc % :link (str "https://sagarvrajalal.com/" (:slug %))))
(map #(dissoc % :slug))
(map #(rename-keys % {:first-published-at :pubDate
:id :guid}))
(apply rss/channel-xml
{:title "Sagar Vrajalal"
:description "Sagar's Blog"
Expand Down
4 changes: 2 additions & 2 deletions src/com/sagar/casa/ui/blog.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
(set! (.-title js/document) title)))


(defn blog-post [{:keys [title html-body description timestamp]}]
(defn blog-post [{:keys [title html-body description date]}]
#?(:cljs (set-page-title! title))
#?(:cljs
[:> Container {:data-theme :light
Expand All @@ -28,7 +28,7 @@
:href routes/blog}
"↰ Back to list"]
[:div
[:i timestamp]
[:i date]
[:h2 title]
[:hr {:style {:border-color :black}}]]
[:> Markup {:attributes {:style {:white-space :pre-wrap}}
Expand Down

0 comments on commit 6f3d9fd

Please sign in to comment.