Browse Source

fix: extracting page's title property from mldoc ast

Tienson Qin 3 years ago
parent
commit
71514ab36c

+ 4 - 3
deps/graph-parser/src/logseq/graph_parser/extract.cljc

@@ -22,9 +22,10 @@
     (if (string/includes? file "pages/contents.")
       "Contents"
       (let [first-block (last (first (filter gp-block/heading-block? ast)))
-            property-name (when (and (contains? #{"Properties" "Property_Drawer"} (ffirst ast))
-                                     (not (string/blank? (:title (last (first ast))))))
-                            (:title (last (first ast))))
+            property-name (when (contains? #{"Properties" "Property_Drawer"} (ffirst ast))
+                            (let [properties-ast (second (first ast))
+                                  properties (zipmap (map (comp keyword first) properties-ast) (map second properties-ast))]
+                              (:title properties)))
             first-block-name (let [title (last (first (:title first-block)))]
                                (and first-block
                                     (string? title)

+ 3 - 3
package.json

@@ -14,6 +14,7 @@
         "del": "^6.0.0",
         "gulp": "^4.0.2",
         "gulp-clean-css": "^4.3.0",
+        "ip": "1.1.8",
         "npm-run-all": "^4.1.5",
         "playwright": "^1.24.2",
         "postcss": "8.4.16",
@@ -26,8 +27,7 @@
         "stylelint": "^13.8.0",
         "stylelint-config-standard": "^20.0.0",
         "tailwindcss": "2.2.16",
-        "typescript": "^4.4.3",
-        "ip": "1.1.8"
+        "typescript": "^4.4.3"
     },
     "scripts": {
         "watch": "run-p gulp:watch cljs:watch",
@@ -109,7 +109,7 @@
         "ignore": "5.1.8",
         "is-svg": "4.3.0",
         "jszip": "3.7.0",
-        "mldoc": "1.4.9",
+        "mldoc": "^1.4.9",
         "path": "0.12.7",
         "pixi-graph-fork": "0.2.0",
         "pixi.js": "6.2.0",

+ 0 - 2
src/main/frontend/components/block.cljs

@@ -1921,8 +1921,6 @@
             (gp-property/property-value-from-content (name k) (:block/content block))
             value)
         property-pages-enabled? (contains? #{true nil} (:property-pages/enabled? user-config))]
-    (prn {:k k
-          :property-separated-by-commas? property-separated-by-commas?})
     [:div
      (if property-pages-enabled?
        (page-cp (assoc config :property? true) {:block/name (subs (str k) 1)})

+ 1 - 1
yarn.lock

@@ -4686,7 +4686,7 @@ mkdirp@^1.0.3:
   resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
   integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
 
[email protected]:
+mldoc@^1.4.9:
   version "1.4.9"
   resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-1.4.9.tgz#a61d93e98f19bf4ec6303810cc3573c5e14eab44"
   integrity sha512-rroc1tWJnNm2n33MYk+sWgLjGWmP93Am+6zvpBe0BGEyccHQT3AxHHv8fNpF7HVvT7YPtU/dtHWTh6nE2n7vPA==