mirror of
https://github.com/tanrax/RSSPAPER.git
synced 2025-11-25 20:16:19 -05:00
Add cover
This commit is contained in:
@@ -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)
|
||||
})))))
|
||||
Reference in New Issue
Block a user