Browse Source

fix: page properties not working when extracting

Tienson Qin 4 năm trước cách đây
mục cha
commit
52ef58b565
1 tập tin đã thay đổi với 15 bổ sung9 xóa
  1. 15 9
      src/main/frontend/format/mldoc.cljs

+ 15 - 9
src/main/frontend/format/mldoc.cljs

@@ -118,15 +118,21 @@
           directive?
           (fn [[item _]] (= "directive" (string/lower-case (first item))))
           grouped-ast (group-by directive? original-ast)
-          [directive-ast other-ast]
-          [(get grouped-ast true) (get grouped-ast false)]
-          properties (->> (map first directive-ast)
-                          (map (fn [[_ k v]]
-                                 (let [k (keyword (string/lower-case k))
-                                       v (if (contains? #{:title :description :roam_tags} k)
-                                           v
-                                           (text/split-page-refs-without-brackets v true))]
-                                   [k v])))
+          directive-ast (get grouped-ast true)
+          [properties-ast other-ast] (if (= "Property_Drawer" (ffirst ast))
+                                       [(last (first ast))
+                                        (rest original-ast)]
+                                       [(->> (map first directive-ast)
+                                             (map rest))
+                                        (get grouped-ast false)])
+          properties (->>
+                      properties-ast
+                      (map (fn [[k v]]
+                             (let [k (keyword (string/lower-case k))
+                                   v (if (contains? #{:title :description :roam_tags} k)
+                                       v
+                                       (text/split-page-refs-without-brackets v true))]
+                               [k v])))
                           (reverse)
                           (into {}))
           macro-properties (filter (fn [x] (= :macro (first x))) properties)