From 19e602bf9c17b0e763340f548ef42ce8dbdee016 Mon Sep 17 00:00:00 2001 From: erik Date: Fri, 17 May 2024 18:31:49 +0200 Subject: [PATCH] Assoc without conj Otherwise the vector is wrapped into a list --- src/main/dda/masto_embed/account_mode.cljs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/dda/masto_embed/account_mode.cljs b/src/main/dda/masto_embed/account_mode.cljs index 23d87dd..d1836a3 100644 --- a/src/main/dda/masto_embed/account_mode.cljs +++ b/src/main/dda/masto_embed/account_mode.cljs @@ -89,6 +89,15 @@ (assoc-in item [:content] (conj content insertion-element))) 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] (if-let [preview-image-url (get-in media_attachments [0 :preview_url])] (let [class-name "mastodon-post-content" @@ -100,7 +109,7 @@ ;; Eventuell das Gleiche auch für masto->media->html (defn insert-link-prev [html] (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] (let [{:keys [url image title description]} card]