feat: search

This commit is contained in:
Tienson Qin
2025-05-26 05:39:09 +08:00
parent 0a65f7d6a9
commit c9044afb3d
5 changed files with 85 additions and 15 deletions

View File

@@ -272,7 +272,7 @@
(recur e-cut new-result)
new-result)))]))
(defn- page-item
(defn page-item
[repo page]
(let [entity (db/entity [:block/uuid (:block/uuid page)])
source-page (model/get-alias-source-page repo (:db/id entity))
@@ -284,14 +284,14 @@
:text title'
:source-page (or source-page page))))
(defn- block-item
[repo block current-page !input]
(defn block-item
[repo block current-page input]
(let [id (:block/uuid block)
text (block-handler/block-unique-title block)
icon "letter-n"]
{:icon icon
:icon-theme :gray
:text (highlight-content-query text @!input)
:text (highlight-content-query text input)
:header (when-not (db/page? block) (block/breadcrumb {:search? true} repo id {}))
:current-page? (when-let [page-id (:block/page block)]
(= page-id (:block/uuid current-page)))
@@ -314,7 +314,7 @@
items (keep (fn [block]
(if (:page? block)
(page-item repo block)
(block-item repo block current-page !input))) blocks)]
(block-item repo block current-page @!input))) blocks)]
(if (= group :current-page)
(let [items-on-current-page (filter :current-page? items)]
(swap! !results update group merge {:status :success :items items-on-current-page}))