[back/feat] redirect zhuanlan URL
This commit is contained in:
parent
f5b2c32de5
commit
7b06316210
1 changed files with 7 additions and 4 deletions
|
@ -10,6 +10,7 @@
|
||||||
[content]
|
[content]
|
||||||
(generate-string content))
|
(generate-string content))
|
||||||
|
|
||||||
|
|
||||||
(defn clean-html
|
(defn clean-html
|
||||||
[docs]
|
[docs]
|
||||||
(-> (.select docs "style[data-emotion-css~=^[a-z0-9]*$]")
|
(-> (.select docs "style[data-emotion-css~=^[a-z0-9]*$]")
|
||||||
|
@ -17,10 +18,11 @@
|
||||||
(vec
|
(vec
|
||||||
(for [a (.select docs "a")]
|
(for [a (.select docs "a")]
|
||||||
(.attr a "href"
|
(.attr a "href"
|
||||||
(url-decode
|
(-> (.attr a "href")
|
||||||
(str/replace
|
(str/replace "https://link.zhihu.com/?target=" "")
|
||||||
(.attr a "href")
|
(str/replace "https://zhuanlan.zhihu.com/p/" "#/item/")
|
||||||
"https://link.zhihu.com/?target=" ""))))))
|
(url-decode))))))
|
||||||
|
|
||||||
|
|
||||||
(defn clean-images
|
(defn clean-images
|
||||||
[docs]
|
[docs]
|
||||||
|
@ -32,6 +34,7 @@
|
||||||
(for [img (.select docs "figure > div > img")]
|
(for [img (.select docs "figure > div > img")]
|
||||||
(.attr img "loading" "lazy"))))
|
(.attr img "loading" "lazy"))))
|
||||||
|
|
||||||
|
|
||||||
(defn fetch-hu-post
|
(defn fetch-hu-post
|
||||||
[request]
|
[request]
|
||||||
(let [id (-> request :path-params :id)
|
(let [id (-> request :path-params :id)
|
||||||
|
|
Loading…
Reference in a new issue