mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-09 06:02:33 +01:00
♻️ Adjust template and widget search data structure (#17142)
This commit is contained in:
parent
87bd6267b7
commit
10dfb0855f
4 changed files with 35 additions and 23 deletions
|
|
@ -26,8 +26,14 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func SearchWidget(keyword string) (ret []*Block) {
|
||||
ret = []*Block{}
|
||||
// WidgetSearchResult 描述了挂件搜索结果。
|
||||
type WidgetSearchResult struct {
|
||||
Name string `json:"name"`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
func SearchWidget(keyword string) (ret []*WidgetSearchResult) {
|
||||
ret = []*WidgetSearchResult{}
|
||||
widgetsDir := filepath.Join(util.DataDir, "widgets")
|
||||
entries, err := os.ReadDir(widgetsDir)
|
||||
if err != nil {
|
||||
|
|
@ -55,7 +61,7 @@ func SearchWidget(keyword string) (ret []*Block) {
|
|||
|
||||
widgets = filterWidgets(widgets, k)
|
||||
for _, widget := range widgets {
|
||||
b := &Block{
|
||||
b := &WidgetSearchResult{
|
||||
Name: bazaar.GetPreferredName(widget.Package),
|
||||
Content: widget.Name,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue