From 6f3d9fdaa4a525125bc12a089f7b018024f35fb0 Mon Sep 17 00:00:00 2001 From: Sagar Vrajalal Date: Mon, 27 May 2024 21:43:46 +0530 Subject: [PATCH] Add `pubDate` to RSS items --- src/com/sagar/casa/api/storyblok.clj | 5 +++-- src/com/sagar/casa/rss.clj | 6 +++++- src/com/sagar/casa/ui/blog.cljc | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/com/sagar/casa/api/storyblok.clj b/src/com/sagar/casa/api/storyblok.clj index 82fafa2..b6c645e 100644 --- a/src/com/sagar/casa/api/storyblok.clj +++ b/src/com/sagar/casa/api/storyblok.clj @@ -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 @@ -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 diff --git a/src/com/sagar/casa/rss.clj b/src/com/sagar/casa/rss.clj index 8d7e5d9..e01c6d1 100644 --- a/src/com/sagar/casa/rss.clj +++ b/src/com/sagar/casa/rss.clj @@ -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" diff --git a/src/com/sagar/casa/ui/blog.cljc b/src/com/sagar/casa/ui/blog.cljc index b62f511..d0f51d5 100644 --- a/src/com/sagar/casa/ui/blog.cljc +++ b/src/com/sagar/casa/ui/blog.cljc @@ -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 @@ -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}}