Add feature: system nav editor in config

This commit is contained in:
Anya Tokugawa committed 2026-05-31 22:44:40 +09:00
1 parent e3a28c9f62
commit e8e9b505af
17 files changed
+409 -156

No files matched your search

+69
View File
@@ -0,0 +1,69 @@
package server
import "strings"
type NavContext struct {
Path string
ObjectUUID string
ObjectURI string
RevisionHash string
}
func expandNavHref(
href string,
ctx NavContext,
) (string, bool) {
replacements := map[string]string{
"{path}": ctx.Path,
"{object_uuid}": ctx.ObjectUUID,
"{object_uri}": ctx.ObjectURI,
"{revision_hash}": ctx.RevisionHash,
}
for key, value := range replacements {
if strings.Contains(href, key) {
if value == "" {
return "", false
}
href =
strings.ReplaceAll(
href,
key,
value,
)
}
}
return href, true
}
func resolveNavItems(
items []NavItem,
ctx NavContext,
) []NavItem {
var out []NavItem
for _, item := range items {
href, ok :=
expandNavHref(
item.Href,
ctx,
)
if !ok {
continue
}
item.ResolvedHref = href
out = append(out, item)
}
return out
}