Nav to Commands
lib / layout
Derives command-palette commands from a dashboard-shell nav config, so a new route reaches both on one commit.
- type
- lib
- files
- 1
- registry deps
- @automindz/command-palette, @automindz/dashboard-shell
- npm deps
- none
installs
- lib/automindz/nav-commands.ts
- One array feeds the sidebar and the palette
- Sections become groups; order is preserved, never sorted
- Nav parents toggle, so their children become a scoped list
navToCommands(nav, { defaultGroup: "Go to" }) turns the sections you already pass to dashboard-shell into palette commands — sections become groups, order is preserved, ids are derived from the route so recents stay stable. Nav parents toggle rather than navigate, so their children become a scoped list; pass flatten to hoist the children and drop the parent instead. Add per-route match terms with keywords.
Variations
one state per section
One array, both surfaces
This palette was not written by hand: navToCommands(NAV) took the same sections the sidebar preview uses and returned the commands. Sections become groups in the order they appear, ids come from the route so recents survive a rename of the label, and the Workspace parent that only toggles in the sidebar became a scoped list rather than a command that navigates nowhere.
Command palette
Search navigation, actions and recents in one list.
Flattened
flatten: true hoists the children to the top level and drops the parent — better when the tree is shallow, since it saves a keystroke and the parent had no page of its own anyway. Same array, same ids, one option.
Command palette
Search navigation, actions and recents in one list.
