Skip to content

Commit 61cc438

Browse files
committed
fix: alias auto-complete
1 parent 9cf01ce commit 61cc438

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/main/frontend/components/cmdk/core.cljs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,11 @@
281281
(defn- page-item
282282
[repo page]
283283
(let [entity (db/entity [:block/uuid (:block/uuid page)])
284-
source-page (model/get-alias-source-page repo (:db/id entity))
284+
source-page (or (:block/title (model/get-alias-source-page repo (:db/id entity)))
285+
(:alias page))
285286
icon (get-page-icon entity)
286287
title (block-handler/block-unique-title page)
287-
title' (if source-page (str title " -> alias: " (:block/title source-page)) title)]
288+
title' (if source-page (str title " -> alias: " source-page) title)]
288289
(hash-map :icon icon
289290
:icon-theme :gray
290291
:text title'

src/main/frontend/components/editor.cljs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@
186186
:item-render (fn [block _chosen?]
187187
(let [block' (if-let [id (:block/uuid block)]
188188
(if-let [e (db/entity [:block/uuid id])]
189-
(assoc e :block/title (:block/title block))
189+
(assoc e
190+
:block/title (:block/title block)
191+
:alias (:alias block))
190192
block)
191193
block)]
192194
[:div.flex.flex-col
@@ -221,12 +223,12 @@
221223
:else
222224
(ui/icon "letter-n" {:size 14}))])
223225

224-
(let [title (let [target (first (:block/_alias block'))
226+
(let [title (let [alias (:alias block')
225227
title (if (and db-based? (not (ldb/built-in? block')))
226228
(block-handler/block-unique-title block')
227229
(:block/title block'))]
228-
(if target
229-
(str title " -> alias: " (:block/title target))
230+
(if alias
231+
(str title " -> alias: " alias)
230232
title))]
231233
(if (or (string/starts-with? title (t :new-tag))
232234
(string/starts-with? title (t :new-page)))

src/main/frontend/worker/search.cljs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ DROP TRIGGER IF EXISTS blocks_au;
325325
(uuid page)
326326
nil)
327327
:block/tags (seq (map :db/id (:block/tags block)))
328-
:page? (ldb/page? block)}))))))
328+
:page? (ldb/page? block)
329+
:alias (:block/title (first (:block/_alias block)))}))))))
329330
page-or-object-result (filter (fn [b] (or (:page? b) (:block/tags result))) result)]
330331
(->>
331332
(concat page-or-object-result

0 commit comments

Comments
 (0)