From 270b4d7822d0afa590ec4e1b2757dced800fcf6b Mon Sep 17 00:00:00 2001 From: SouthFox Date: Sun, 27 Aug 2023 13:29:51 +0800 Subject: [PATCH] [back/feat] render linkCard --- src/main/backend/handlers.clj | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/backend/handlers.clj b/src/main/backend/handlers.clj index b520f04..97dd000 100644 --- a/src/main/backend/handlers.clj +++ b/src/main/backend/handlers.clj @@ -35,6 +35,13 @@ (.attr img "loading" "lazy")))) +(defn render-linkcard + [docs] + (doseq [link-card (.select docs "a.LinkCard > span.LinkCard-contents")] + (.empty link-card) + (.append link-card (.attr (.parent link-card) "data-text")))) + + (defn fetch-hu-post [request] (let [id (-> request :path-params :id) @@ -44,8 +51,9 @@ docs (.getElementsByClass page "Post-RichTextContainer")] (clean-html docs) (clean-images docs) + (render-linkcard docs) (let [content {:content (.toString docs) :title (.text title)}] - {:status 200 - :headers {"Content-Type" "application/json; charset=utf-8"} - :body (wrap-json content)}))) + {:status 200 + :headers {"Content-Type" "application/json; charset=utf-8"} + :body (wrap-json content)})))