[feat] show post publish (or edit) time

This commit is contained in:
SouthFox 2023-08-28 22:54:05 +08:00
parent b0c52c2e89
commit b690e71ce8
2 changed files with 5 additions and 2 deletions

View file

@ -46,12 +46,14 @@
post-url (str/join ["https://zhuanlan.zhihu.com/p/" id])
page (-> (client/get post-url) :body Jsoup/parse)
title (.getElementsByClass page "Post-Title")
post-time (.getElementsByClass page "ContentItem-time")
docs (.getElementsByClass page "Post-RichTextContainer")]
(clean-html docs)
(clean-images docs)
(render-linkcard docs)
(let [content {:content (.toString docs)
:title (.text title)}]
:title (.text title)
:time (first (str/split (.text post-time) #"・"))}]
{:status 200
:headers {"Content-Type" "application/json; charset=utf-8"}
:body (wrap-json content)})))

View file

@ -36,7 +36,8 @@
[:p "Loading..."]
[:div
[:div {:class "text-2xl"}
[:h1 (:title post)]]
[:h1 (:title post)]
[:time (:time post)]]
[:div
{:dangerouslySetInnerHTML
{:__html (:content post)}}]])))