Skip to content

Commit fd52fb5

Browse files
committed
fix: search highlights doesn't work for pages
fix logseq/db-test#633
1 parent bef3939 commit fd52fb5

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,21 @@
274274
new-result)))]))
275275

276276
(defn page-item
277-
[repo page]
278-
(let [entity (db/entity [:block/uuid (:block/uuid page)])
277+
[repo page input]
278+
(let [entity (-> (or (db/entity [:block/uuid (:block/uuid page)]) page)
279+
(update :block/tags (fn [tags]
280+
(map (fn [tag]
281+
(if (integer? tag)
282+
(db/entity tag)
283+
tag)) tags))))
279284
source-page (or (model/get-alias-source-page repo (:db/id entity))
280285
(:alias page))
281286
icon (icon-component/get-node-icon-cp entity {:ignore-current-icon? true})
282-
title (block-handler/block-unique-title (or entity page)
287+
title (block-handler/block-unique-title entity
283288
{:alias (:block/title source-page)})]
284289
(hash-map :icon icon
285290
:icon-theme :gray
286-
:text title
291+
:text (highlight-content-query title input)
287292
:header (when (:block/parent entity)
288293
(block/breadcrumb {:disable-preview? true
289294
:search? true} repo (:block/uuid page)
@@ -321,8 +326,9 @@
321326
(p/let [blocks (search/block-search repo @!input opts)
322327
blocks (remove nil? blocks)
323328
items (keep (fn [block]
329+
(prn :debug :block block)
324330
(if (:page? block)
325-
(page-item repo block)
331+
(page-item repo block @!input)
326332
(block-item repo block current-page @!input))) blocks)]
327333
(if (= group :current-page)
328334
(let [items-on-current-page (filter :current-page? items)]

src/main/mobile/search.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
:extract-fn :block/title})
2020
items (keep (fn [block]
2121
(if (:page? block)
22-
(assoc (cmdk/page-item repo block) :page? true)
22+
(assoc (cmdk/page-item repo block input) :page? true)
2323
(cmdk/block-item repo block nil input))) blocks)]
2424
items))
2525

0 commit comments

Comments
 (0)