pull/645/head
Tienson Qin 2020-05-24 12:29:57 +08:00
parent 8ad4097987
commit 326bebca51
3 changed files with 16 additions and 11 deletions

View File

@ -437,15 +437,14 @@
collapsed? (or toggle-collapsed? @collapsed-atom?)
agenda? (= (:id config) "agenda")
start-level (or (:start-level config) 1)]
[:<>
[:div {:key (str uuid)}
(if show-page?
(let [page (db/entity (:db/id page))]
[:a.page-ref {:href (str "/page/" (util/url-encode (:page/name page)))}
(util/capitalize-all (:page/name page))]))
(when-not lock?
[:div.ls-heading-parent.flex-1
{:key (str uuid)
:id heading-id
{:id heading-id
:headingid (str uuid)
:level level
:class (if dummy? "dummy")}
@ -511,9 +510,10 @@
nil))
(defn heading
(rum/defc heading
[config {:heading/keys [uuid title tags marker level priority anchor meta numbering children format]
:as t}]
(prn "re-render")
(let [config (assoc config :heading t)
agenda? (= (:id config) "agenda")
checkbox (heading-checkbox t
@ -728,7 +728,7 @@
;; TODO: handle case of no headings
(defn ->hiccup
[headings config]
(let [headings (map-indexed (fn [idx heading] ["Heading" (assoc heading :heading/idx idx)]) headings)
(let [headings (map (fn [heading] ["Heading" heading]) headings)
blocks (blocks config headings)]
(->elem
:div.content

View File

@ -13,14 +13,16 @@
[frontend.utf8 :as utf8]
[goog.object :as gobj]))
(rum/defc journal-cp
(rum/defc journal-cp < rum/reactive
[[title headings format]]
(let [;; Don't edit the journal title
page (string/lower-case title)
headings (db/get-page-headings page)
headings (when (seq headings)
(update (vec headings) 0 assoc :heading/lock? true))
headings (db/with-dummy-heading headings format nil true)
encoded-page-name (util/url-encode (string/lower-case title))]
encoded-page-name (util/url-encode page)]
[:div.flex-1
[:a.initial-color {:href (str "/page/" encoded-page-name)
:on-click (fn [e]
@ -46,8 +48,8 @@
[latest-journals]
[:div#journals
(ui/infinite-list
(for [[journal-name body format] latest-journals]
(for [[journal-name format] latest-journals]
[:div.journal.content {:key journal-name}
(journal-cp [journal-name body format])])
(journal-cp [journal-name format])])
{:on-load (fn []
(handler/load-more-journals!))})])

View File

@ -498,7 +498,10 @@
page)
react
seq-flatten
sort-by-pos))))
sort-by-pos
(map (fn [heading]
(dissoc heading :meta)))
))))
(defn get-page-name
[file ast]
@ -768,7 +771,7 @@
(mapv
(fn [page]
[page
(get-page-headings repo-url page)
;; (get-page-headings repo-url page)
(get-page-format page)])
pages))))