fix: indexing whiteboard page files

pull/6112/head
Peng Xiao 2022-07-04 00:41:29 +08:00
parent 4de59c6d63
commit fb832d2493
3 changed files with 25 additions and 14 deletions

View File

@ -67,8 +67,9 @@
files)
support-files (sort-by :file/path support-files)
{journals true non-journals false} (group-by (fn [file] (string/includes? (:file/path file) "journals/")) support-files)
{whiteboards true non-whiteboards false} (group-by (fn [file] (string/includes? (:file/path file) "whiteboards/")) non-journals)
{built-in true others false} (group-by (fn [file]
(or (string/includes? (:file/path file) "contents.")
(string/includes? (:file/path file) ".edn")
(string/includes? (:file/path file) "custom.css"))) non-journals)]
(concat (reverse journals) built-in others)))
(string/includes? (:file/path file) "custom.css"))) non-whiteboards)]
(concat (reverse journals) (reverse whiteboards) built-in others)))

View File

@ -15,11 +15,17 @@
(gp-util/safe-re-find (re-pattern (str "^[./]*" local-assets-dir)) s))
(defonce default-draw-directory "draws")
;; TODO read configurable value?
(defonce default-whiteboards-directory "whiteboards")
(defn draw?
[path]
(string/starts-with? path default-draw-directory))
(defn whiteboard?
[path]
(string/includes? path (str "/" default-whiteboards-directory "/")))
;; TODO: rename
(defonce mldoc-support-formats
#{:org :markdown :md})

View File

@ -71,20 +71,24 @@
(assoc
(gp-block/page-name->map page false db true date-formatter)
:block/file {:file/path (gp-util/path-normalize file)}))
(seq properties)
(assoc :block/properties properties)
(seq properties)
(assoc :block/properties properties)
(seq aliases)
(assoc :block/alias aliases)
(seq aliases)
(assoc :block/alias aliases)
(:tags properties)
(assoc :block/tags (let [tags (:tags properties)
tags (if (string? tags) [tags] tags)
tags (remove string/blank? tags)]
(swap! ref-tags set/union (set tags))
(map (fn [tag] {:block/name (gp-util/page-name-sanity-lc tag)
:block/original-name tag})
tags))))))
(gp-config/whiteboard? file)
(assoc :block/whiteboard? true)
(:tags properties)
(assoc :block/tags (let [tags (:tags properties)
tags (if (string? tags) [tags] tags)
tags (remove string/blank? tags)]
(swap! ref-tags set/union (set tags))
(map (fn [tag] {:block/name (gp-util/page-name-sanity-lc tag)
:block/original-name tag})
tags))))))
;; TODO: performance improvement
(defn- extract-pages-and-blocks