[back/feat] redirect zhuanlan URL

This commit is contained in:
SouthFox 2023-08-27 12:52:22 +08:00
parent f5b2c32de5
commit 7b06316210

View file

@ -10,6 +10,7 @@
[content]
(generate-string content))
(defn clean-html
[docs]
(-> (.select docs "style[data-emotion-css~=^[a-z0-9]*$]")
@ -17,10 +18,11 @@
(vec
(for [a (.select docs "a")]
(.attr a "href"
(url-decode
(str/replace
(.attr a "href")
"https://link.zhihu.com/?target=" ""))))))
(-> (.attr a "href")
(str/replace "https://link.zhihu.com/?target=" "")
(str/replace "https://zhuanlan.zhihu.com/p/" "#/item/")
(url-decode))))))
(defn clean-images
[docs]
@ -32,6 +34,7 @@
(for [img (.select docs "figure > div > img")]
(.attr img "loading" "lazy"))))
(defn fetch-hu-post
[request]
(let [id (-> request :path-params :id)