feat: move all created pages to library

This commit is contained in:
Tienson Qin
2025-05-14 18:24:40 +08:00
parent 61d5aa3605
commit 349dbec466
2 changed files with 20 additions and 6 deletions

View File

@@ -156,7 +156,10 @@
untitled? (t :untitled)
:else (let [title' (pdf-utils/fix-local-asset-pagename title)
parent (:block/parent page)]
(if (and parent (not (ldb/class? page)))
(if (and parent
(not (or (ldb/class? page)
(and (:logseq.property/built-in? parent)
(= (:block/title parent) "Library")))))
(str (:block/title parent) ns-util/parent-char title')
title')))]

View File

@@ -165,11 +165,20 @@
[page])
(remove nil?))))
(defn- page-with-parent-and-order
[db page]
(let [library (ldb/get-page db "Library")]
(when (nil? library)
(throw (ex-info "Library page doesn't exist" {})))
(assoc page
:block/parent (:db/id library)
:block/order (db-order/gen-key nil nil))))
(defn create
"Pure function without side effects"
[db title*
{:keys [create-first-block? tags properties uuid persist-op? whiteboard?
class? today-journal? split-namespace?]
class? today-journal? split-namespace? reference?]
:or {create-first-block? true
properties nil
uuid nil
@@ -201,10 +210,12 @@
[:db/retract [:block/uuid (:block/uuid existing-page)] :block/tags :logseq.class/Page]]]
{:tx-meta tx-meta
:tx-data tx-data})))
(let [page (gp-block/page-name->map title db true date-formatter
{:class? class?
:page-uuid (when (uuid? uuid) uuid)
:skip-existing-page-check? true})
(let [page (->>
(gp-block/page-name->map title db true date-formatter
{:class? class?
:page-uuid (when (uuid? uuid) uuid)
:skip-existing-page-check? true})
(page-with-parent-and-order db))
[page parents] (if (and (text/namespace-page? title) split-namespace?)
(let [pages (split-namespace-pages db page date-formatter)]
[(last pages) (butlast pages)])