enhance: filter recently updated when input

Also, don't show new page for built-in files
This commit is contained in:
Tienson Qin
2025-05-16 00:07:43 +08:00
parent 09b333a5c3
commit 765568bd4e

View File

@@ -81,7 +81,9 @@
(string/replace input #"^#+" ""))
(defn create-items [q]
(when (and (not (string/blank? q)) (not config/publishing?))
(when (and (not (string/blank? q))
(not (#{"config.edn" "custom.js" "custom.css"} q))
(not config/publishing?))
(let [class? (string/starts-with? q "#")]
(->> [{:text (if class? "Create tag" "Create page") :icon "new-page"
:icon-theme :gray
@@ -236,6 +238,25 @@
(hash-map :status :success :items)
(swap! !results update group merge)))))
(defmethod load-results :recently-updated-pages [group state]
(let [!input (::input state)
!results (::results state)]
(swap! !results assoc-in [group :status] :loading)
(let [recent-pages (ldb/get-recent-updated-pages (db/get-db))
search-results (if (string/blank? @!input)
recent-pages
(search/fuzzy-search recent-pages @!input {:extract-fn :block/title}))]
(->> search-results
(map (fn [block]
(let [text (block-handler/block-unique-title block)
icon (get-page-icon block)]
{:icon icon
:icon-theme :gray
:text text
:source-block block})))
(hash-map :status :success :items)
(swap! !results update group merge)))))
(defn highlight-content-query
"Return hiccup of highlighted content FTS result"
[content q]
@@ -396,6 +417,7 @@
(load-results :nodes state)
(load-results :filters state)
(load-results :files state)
(load-results :recently-updated-pages state)
;; (load-results :recents state)
)))))