docs(ui): drop sidebar saved-state — server defaults already ARE the standard docs behavior
Simplification per spec: the menu tracks state through the URL alone. Land on /docs: fully closed, headers only (an explicit home rule now overrides the contains-URL rule, since the root overview doc lives in Getting Started and would otherwise auto-open it). Land on any doc page: its containing section + group render open at first paint, current link bold — no JS, no jump, arrows consistent. Navigate elsewhere: old closes, new opens. Deleted: docs_nav cookie const/parse, ApplyNavOverrides, cookie write + collect/persist helpers in web/src/docs.ts, data-key attributes in the sidebar templ, and the first-section-open fallback (docs home used to force-open the first section — spec'd as closed). toggleCollapsible remains for in-page peeking; purely ephemeral. The [data-collapsed=true] CSS from the previous round stays — it is what makes the server-rendered state actually hide sections at paint (the original bug was that this CSS never existed). Tests: TestBuildNavigationNothingCurrent now asserts zero sections open on unmatched paths; TestBuildNavigation asserts Getting Started closed on a device page (no site-wide pin). make test green; 146 vitests; live verified: home 0 expanded, doc pages exactly 2 (section+group).
This commit is contained in:
1 parent
a8f8c4def9
commit
73e8cdef4b
6 files changed
+155
-272
No files matched your search
@@ -198,7 +198,7 @@ templ DocsSidebar(nav Navigation, currentPath string) {
|
||||
@Icon("chevron-down", "h-4 w-4")
|
||||
</span>
|
||||
</button>
|
||||
<div class="nav-items pb-1" data-key={ section.Title } data-collapsed={ collapsibleState(section.Collapsed) }>
|
||||
<div class="nav-items pb-1" data-collapsed={ collapsibleState(section.Collapsed) }>
|
||||
for _, item := range section.Items {
|
||||
<a href={ item.URL } class={ docsNavClass(currentPath, item.URL, "pl-7") }>
|
||||
<span>{ item.Title }</span>
|
||||
@@ -217,7 +217,7 @@ templ DocsSidebar(nav Navigation, currentPath string) {
|
||||
@Icon("chevron-down", "h-3.5 w-3.5")
|
||||
</span>
|
||||
</button>
|
||||
<div class="nav-group-items" data-key={ section.Title + " / " + group.Title } data-collapsed={ collapsibleState(group.Collapsed) }>
|
||||
<div class="nav-group-items" data-collapsed={ collapsibleState(group.Collapsed) }>
|
||||
for _, item := range group.Items {
|
||||
<a href={ item.URL } class={ docsNavClass(currentPath, item.URL, "pl-9") }>
|
||||
<span class="truncate">{ item.Title }</span>
|
||||
|
||||
Reference in new issue
Block a user