Browse Source

fix: indexing whiteboard page files

Peng Xiao 3 years ago
parent
commit
fb832d2493

+ 3 - 2
deps/graph-parser/src/logseq/graph_parser.cljs

@@ -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)))

+ 6 - 0
deps/graph-parser/src/logseq/graph_parser/config.cljs

@@ -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})

+ 16 - 12
deps/graph-parser/src/logseq/graph_parser/extract.cljc

@@ -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