Sidebar: no container without NavItems
A page that clears NavItems (yasta's login page) still got the empty nav container, which the modern style draws as a card: an empty frame where the sidebar would be. The container is now left out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3e99ada77b
commit
00a1e4b895
2 files changed
+18
-2
No files matched your search
@@ -103,3 +103,19 @@ func TestSidebarGroupsAndIcons(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A page without NavItems (a login page) renders no sidebar container:
|
||||
// the modern style draws it as a card, which would show up empty.
|
||||
func TestSidebarWithoutItems(t *testing.T) {
|
||||
r, err := NewRenderer(testPagesFS(), "pages", []string{"dashboard"}, ".html.tmpl", testFuncs())
|
||||
if err != nil {
|
||||
t.Fatalf("NewRenderer: %v", err)
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
if err := r.Page(&buf, "dashboard", PageHeader{Title: "Log in"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if strings.Contains(buf.String(), `class="nav flex-column`) {
|
||||
t.Errorf("empty sidebar container rendered\n---\n%s", buf.String())
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{{define "sidebar"}}
|
||||
<div class="nav flex-column pt-2">
|
||||
{{if .NavItems}}<div class="nav flex-column pt-2">
|
||||
{{range .SidebarEntries}}{{if .GroupHead}}<div class="yw-nav-group">{{.GroupHead}}</div>
|
||||
{{end}}<a class="nav-link{{if .Active}} active{{end}}" href="{{$.BasePath}}{{.Href}}"{{if .Active}} aria-current="page"{{end}}>{{if .IconSVG}}<span class="yw-nav-icon" aria-hidden="true">{{.IconSVG}}</span>{{end}}{{.Label}}</a>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>{{end}}
|
||||
{{end}}
|
||||
Reference in new issue
Block a user