enhance(plugin): support custom routes from the plugin sdk

This commit is contained in:
charlie
2024-03-21 19:07:16 +08:00
parent bd26d0db0e
commit 53125d6315
11 changed files with 124 additions and 50 deletions

View File

@@ -12,6 +12,7 @@
[frontend.search :as search]
[frontend.util :as util]
[frontend.mixins :as mixins]
[frontend.config :as config]
[logseq.shui.ui :as shui]
[electron.ipc :as ipc]
[promesa.core :as p]
@@ -1426,3 +1427,13 @@
(focused-settings-content title)])
{:label "plugin-settings-modal"
:id "ls-focused-settings-modal"}))
(defn hook-custom-routes
[routes]
(cond-> routes
config/lsp-enabled?
(concat (some->> (plugin-handler/hook-routes-renderer)
(mapv #(when-let [{:keys [name path render]} %]
(when (not (string/blank? path))
[path {:name name :view (fn [r] (render r %))}])))
(remove nil?)))))