add configuration: top nav order and settings

This commit is contained in:
Anya Tokugawa committed 2026-05-31 21:10:01 +09:00
1 parent d300354725
commit 12decb7862
9 files changed
+386 -71

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
package server
import (
"encoding/json"
)
type NavItem struct {
Label string `json:"label"`
Href string `json:"href"`
}
func defaultNavItems() []NavItem {
return []NavItem{
{
Label: "Home",
Href: "/",
},
{
Label: "Tree",
Href: "/v/tree",
},
{
Label: "Config",
Href: "/-/sys/config",
},
}
}
func (s *Server) getNavItems() []NavItem {
raw, err :=
s.store.GetConfig(
"nav_items",
)
if err != nil ||
raw == "" {
return defaultNavItems()
}
var items []NavItem
err = json.Unmarshal(
[]byte(raw),
&items,
)
if err != nil ||
len(items) == 0 {
return defaultNavItems()
}
return items
}