fix: link property causes wrong pages creation

This commit is contained in:
llcc
2022-03-06 19:10:50 +08:00
committed by Tienson Qin
parent 965bedf4fa
commit f02c21c95b
3 changed files with 23 additions and 6 deletions

View File

@@ -8,7 +8,8 @@
[lambdaisland.glogi :as log]
[medley.core :as medley]
["mldoc" :as mldoc :refer [Mldoc]]
[linked.core :as linked]))
[linked.core :as linked]
[frontend.config :as config]))
(defonce parseJson (gobj/get Mldoc "parseJson"))
(defonce parseInlineJson (gobj/get Mldoc "parseInlineJson"))
@@ -263,6 +264,17 @@
(defn link?
[format link]
(when (string? link)
(let [[type link] (first (inline->edn link (default-config format)))]
(let [[type link] (first (inline->edn link (default-config format)))
[ref-type ref-value] (:url link)]
(and (= "Link" type)
(not (contains? #{"Page_ref" "Block_ref"} (first (:url link))))))))
(or
;; 1. url
(not (contains? #{"Page_ref" "Block_ref"} ref-type))
(and (contains? #{"Page_ref"} ref-type)
(or
;; 2. excalidraw link
(config/draw? ref-value)
;; 3. local asset link
(boolean (config/local-asset? ref-value)))))))))