fix: missing title properties when page name contains / or reserved chars

Close #5171
This commit is contained in:
Tienson Qin
2022-05-07 00:39:09 +08:00
parent 2d30f1429d
commit 362c328e91
4 changed files with 29 additions and 17 deletions

View File

@@ -91,12 +91,16 @@
(defn- build-page-tx [format properties page journal?]
(when (:block/uuid page)
(let [page-entity [:block/uuid (:block/uuid page)]
create-title? (create-title-property? journal? (:block/name page))
create-title? (create-title-property? journal?
(or
(:block/original-name page)
(:block/name page)))
page (if (seq properties) (assoc page :block/properties properties) page)]
(cond
create-title?
[page
(default-properties-block (build-title page) format page-entity properties)]
(let [properties-block (default-properties-block (build-title page) format page-entity properties)]
[page
properties-block])
(seq properties)
[page (editor-handler/properties-block properties format page-entity)]
@@ -117,7 +121,7 @@
title (util/remove-boundary-slashes title)
page-name (util/page-name-sanity-lc title)
repo (state/get-current-repo)]
(when-not (db/page-exists? page-name)
(when (db/page-empty? repo page-name)
(let [pages (if split-namespace?
(util/split-namespace-pages title)
[title])
@@ -133,13 +137,14 @@
(remove nil?))
last-txs (build-page-tx format properties (last pages) journal?)
txs (concat txs last-txs)]
(db/transact! txs)))
(when (seq txs)
(db/transact! txs)))
(when create-first-block?
(when (or
(db/page-empty? repo (:db/id (db/entity [:block/name page-name])))
(create-title-property? journal? page-name))
(editor-handler/api-insert-new-block! "" {:page page-name})))
(when create-first-block?
(when (or
(db/page-empty? repo (:db/id (db/entity [:block/name page-name])))
(create-title-property? journal? page-name))
(editor-handler/api-insert-new-block! "" {:page page-name}))))
(when redirect?
(route-handler/redirect-to-page! page-name))