fix: remove built-in properties from search results

Close #10573
pull/10603/merge
Tienson Qin 2023-11-30 14:30:49 +08:00
parent 416e1477f9
commit 567fb31148
1 changed files with 10 additions and 7 deletions

View File

@ -4,7 +4,8 @@
[frontend.db :as db]
[frontend.state :as state]
[frontend.util :as util]
["fuse.js" :as fuse]))
["fuse.js" :as fuse]
[frontend.util.property :as property-util]))
;; Notice: When breaking changes happen, bump version in src/electron/electron/search.cljs
@ -21,13 +22,15 @@
(defn block->index
"Convert a block to the index for searching"
[{:block/keys [uuid page content] :as block}]
[{:block/keys [uuid page content format] :as block
:or {format :markdown}}]
(when-not (> (count content) (max-len))
(when-not (string/blank? content)
{:id (:db/id block)
:uuid (str uuid)
:page page
:content (sanitize content)})))
(let [content (property-util/remove-built-in-properties format content)]
(when-not (string/blank? content)
{:id (:db/id block)
:uuid (str uuid)
:page page
:content (sanitize content)}))))
(defn page->index
"Convert a page name to the index for searching (page content level)