Assoc without conj

Otherwise the vector is wrapped into a list
This commit is contained in:
erik 2024-05-17 18:31:49 +02:00
parent 644717d272
commit 19e602bf9c

View file

@ -89,6 +89,15 @@
(assoc-in item [:content] (conj content insertion-element))) (assoc-in item [:content] (conj content insertion-element)))
item))) item)))
(defn assoc-to-content [item class insertion-element]
(let [condition (every? true? [(map? item)
(= (:type item) :element)
(= class (:class (:attrs item)))])]
(if condition
(let [content (:content item)]
(assoc-in item [:content] insertion-element))
item)))
(defn masto-media->html [html media_attachments] (defn masto-media->html [html media_attachments]
(if-let [preview-image-url (get-in media_attachments [0 :preview_url])] (if-let [preview-image-url (get-in media_attachments [0 :preview_url])]
(let [class-name "mastodon-post-content" (let [class-name "mastodon-post-content"
@ -100,7 +109,7 @@
;; Eventuell das Gleiche auch für masto->media->html ;; Eventuell das Gleiche auch für masto->media->html
(defn insert-link-prev [html] (defn insert-link-prev [html]
(let [class-name "mastodon-post-link-preview"] (let [class-name "mastodon-post-link-preview"]
(postwalk #(insert-into-class % class-name link_preview) html))) (postwalk #(assoc-to-content % class-name link_preview) html)))
(defn masto-link-prev->html [html card] (defn masto-link-prev->html [html card]
(let [{:keys [url image title description]} card] (let [{:keys [url image title description]} card]