Fix: create wrong pages if nested_link exist in graph

Let's say, if `[[[[A/B]] is page]] got referenced` exists as a link in
the graph, a `[[A` will be created. This PR fixes this issue.
This commit is contained in:
leizhe
2021-11-22 09:50:11 +08:00
committed by Tienson Qin
parent d84fec72e5
commit 4779a5c98b
2 changed files with 11 additions and 3 deletions

View File

@@ -262,6 +262,7 @@
(let [original-page-name (util/remove-boundary-slashes original-page-name)
[original-page-name page-name journal-day] (convert-page-if-journal original-page-name)
namespace? (and (string/includes? original-page-name "/")
(not (boolean (text/get-nested-page-name original-page-name)))
(text/namespace-page? original-page-name))
m (merge
{:block/name page-name
@@ -302,10 +303,12 @@
(concat title body))
(let [refs (remove string/blank? @refs)
children-pages (->> (mapcat (fn [p]
(when (text/namespace-page? p)
(util/split-namespace-pages p)))
(let [p (or (text/get-nested-page-name p) p)]
(when (text/namespace-page? p)
(util/split-namespace-pages p))))
refs)
(remove string/blank?))
(remove string/blank?)
(distinct))
refs (->> (distinct (concat refs children-pages))
(remove nil?))
refs (map (fn [ref] (page-name->map ref with-id?)) refs)]