diff --git a/src/main/backend/handlers.clj b/src/main/backend/handlers.clj index 7bc6e82..72088a6 100644 --- a/src/main/backend/handlers.clj +++ b/src/main/backend/handlers.clj @@ -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)}))) diff --git a/src/main/frontend/views.cljs b/src/main/frontend/views.cljs index acccffd..c7d8e61 100644 --- a/src/main/frontend/views.cljs +++ b/src/main/frontend/views.cljs @@ -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)}}]])))