Add cover

This commit is contained in:
Andros Fenollosa
2021-06-30 00:41:21 +02:00
parent 09aff8568f
commit 4b91adf208
4 changed files with 19 additions and 2 deletions

View File

@@ -4,6 +4,19 @@
[rsspaper.config :refer [config]]
[selmer.parser :as s]))
(defn add-cover-article
[data]
;; Add cover to article search first image in description
;; Iterate every blog
(map (fn [blog]
;; Replace entries
(assoc-in blog [:feed :entries]
;; New entries with add cover
(map (fn [article]
(assoc article :cover (second (re-find #"<img[^>]+src=\"([^\">]+)\"" (str (get-in article [:description :value]))))))
(get-in blog [:feed :entries])) )
) data))
(defn make-html
[data]
;; Render html in dist/index.html
@@ -17,5 +30,5 @@
(with-open [wrtr (io/writer path)]
(.write wrtr (s/render-file (str "themes/" (:theme config) ".html") {
:title (:title config)
:data data
:data (add-cover-article data)
})))))