[feat] show post publish (or edit) time
This commit is contained in:
parent
b0c52c2e89
commit
b690e71ce8
2 changed files with 5 additions and 2 deletions
|
@ -46,12 +46,14 @@
|
||||||
post-url (str/join ["https://zhuanlan.zhihu.com/p/" id])
|
post-url (str/join ["https://zhuanlan.zhihu.com/p/" id])
|
||||||
page (-> (client/get post-url) :body Jsoup/parse)
|
page (-> (client/get post-url) :body Jsoup/parse)
|
||||||
title (.getElementsByClass page "Post-Title")
|
title (.getElementsByClass page "Post-Title")
|
||||||
|
post-time (.getElementsByClass page "ContentItem-time")
|
||||||
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)
|
(render-linkcard docs)
|
||||||
(let [content {:content (.toString docs)
|
(let [content {:content (.toString docs)
|
||||||
:title (.text title)}]
|
:title (.text title)
|
||||||
|
:time (first (str/split (.text post-time) #"・"))}]
|
||||||
{: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)})))
|
||||||
|
|
|
@ -36,7 +36,8 @@
|
||||||
[:p "Loading..."]
|
[:p "Loading..."]
|
||||||
[:div
|
[:div
|
||||||
[:div {:class "text-2xl"}
|
[:div {:class "text-2xl"}
|
||||||
[:h1 (:title post)]]
|
[:h1 (:title post)]
|
||||||
|
[:time (:time post)]]
|
||||||
[:div
|
[:div
|
||||||
{:dangerouslySetInnerHTML
|
{:dangerouslySetInnerHTML
|
||||||
{:__html (:content post)}}]])))
|
{:__html (:content post)}}]])))
|
||||||
|
|
Loading…
Reference in a new issue