Improved breadcrumbs list

This commit is contained in:
Anya Tokugawa committed 2026-05-31 23:39:12 +09:00
1 parent 2b4e1dbc57
commit ea3eba180b
4 files changed
+100 -36

No files matched your search

+21 -8
View File
@@ -11,12 +11,18 @@ func buildBreadcrumbs(
path string,
) []Breadcrumb {
path = cleanSemanticPath(path)
path =
strings.TrimSpace(path)
if path == "/" {
if path == "" ||
path == "/" {
return nil
}
if !strings.HasPrefix(path, "/") {
path = "/" + path
}
parts :=
strings.Split(
strings.Trim(path, "/"),
@@ -26,14 +32,21 @@ func buildBreadcrumbs(
var out []Breadcrumb
current := ""
for _, p := range parts {
for _, part := range parts {
current += "/" + p
if part == "" {
continue
}
out = append(out, Breadcrumb{
Name: p,
Path: current,
})
current += "/" + part
out = append(
out,
Breadcrumb{
Name: part,
Path: current,
},
)
}
return out
+5 -3
View File
@@ -82,9 +82,11 @@ func (s *Server) handleHome(
ObjectURI: "uuid:" + objectUUID,
},
),
"Title": homePath,
"Path": homePath,
"ObjectUUID": objectUUID,
"IsHome": true,
"Title": homePath,
"Path": homePath,
"Breadcrumbs": buildBreadcrumbs(homePath),
"ObjectUUID": objectUUID,
"RenderedHTML": template.HTML(
rendered,
),
+8 -3
View File
@@ -2,6 +2,7 @@ package server
import (
"html/template"
"log"
"net/http"
"strings"
)
@@ -39,6 +40,9 @@ func (s *Server) handleSemanticRoute(
return
}
bs := buildBreadcrumbs(path)
log.Printf("breadcrumb debug path=%s bs=%#v", path, bs)
rendered :=
s.expandMacros(
latest.Body,
@@ -49,9 +53,10 @@ func (s *Server) handleSemanticRoute(
w,
"page.gohtml",
map[string]any{
"Title": path,
"Path": path,
"ObjectUUID": objectUUID,
"Title": path,
"Path": path,
"Breadcrumbs": buildBreadcrumbs(path),
"ObjectUUID": objectUUID,
"NavItems": resolveNavItems(
s.getSystemNavItems(),
NavContext{