docs(admin): document active item and breadcrumb logic for nav registration

- add note in DEV.md explaining basePath auto-deduction and breadcrumb slug convention
- update README.md to document new `basePath` param in `registerNavItem` and detail active item/breadcrumb behavior
- update navigation file listing in README.md to include new exported helpers
- implement `getNavItemBasePath` and `findActiveNavContext` in navigation.js
- use `basePath` in AdminSidebar to determine active item via longest-prefix match
- use `basePath` in AdminTop to build breadcrumb with section, item, and action labels
- expose new navigation helpers from admin index.js and registry.js
This commit is contained in:
2026-04-26 19:40:40 -04:00
parent 2d76b56deb
commit fbcaed6816
7 changed files with 192 additions and 39 deletions
+3 -3
View File
@@ -21,7 +21,7 @@ if (!globalThis[REGISTRY_KEY]) {
globalThis[REGISTRY_KEY] = {
widgetFetchers: new Map(), // id -> async () => data
widgetComponents: new Map(), // id -> { Component, order, permission }
navItems: new Map(), // id -> { id, label, icon, href, order, sectionId, position, permission }
navItems: new Map(), // id -> { id, label, icon, href, basePath, order, sectionId, position, permission }
navSections: new Map(), // id -> { id, title, icon, order }
pages: new Map(), // slug -> { slug, Component, title?, breadcrumbLabel? }
};
@@ -66,8 +66,8 @@ export function registerNavSection({ id, title, icon, order = 0 }) {
navSections.set(id, { id, title, icon, order });
}
export function registerNavItem({ id, label, icon, href, order = 0, sectionId = 'main', position, permission }) {
navItems.set(id, { id, label, icon, href, order, sectionId, position, permission });
export function registerNavItem({ id, label, icon, href, basePath, order = 0, sectionId = 'main', position, permission }) {
navItems.set(id, { id, label, icon, href, basePath, order, sectionId, position, permission });
}
export function getNavSections() {