[back/feat] render linkCard

This commit is contained in:
SouthFox 2023-08-27 13:29:51 +08:00
parent 7b06316210
commit 270b4d7822

View file

@ -35,6 +35,13 @@
(.attr img "loading" "lazy")))) (.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 (defn fetch-hu-post
[request] [request]
(let [id (-> request :path-params :id) (let [id (-> request :path-params :id)
@ -44,8 +51,9 @@
docs (.getElementsByClass page "Post-RichTextContainer")] docs (.getElementsByClass page "Post-RichTextContainer")]
(clean-html docs) (clean-html docs)
(clean-images docs) (clean-images docs)
(render-linkcard docs)
(let [content {:content (.toString docs) (let [content {:content (.toString docs)
:title (.text title)}] :title (.text title)}]
{:status 200 {:status 200
:headers {"Content-Type" "application/json; charset=utf-8"} :headers {"Content-Type" "application/json; charset=utf-8"}
:body (wrap-json content)}))) :body (wrap-json content)})))