cmdk
cmdk copied to clipboard
discussion: better way for 'routing'
I am just curious, and want to find a better way for routing, navigating between pages.
the example navigates on top level element:
activePage === 'xxx' && <Component1 />
activePage === 'xxxx' && <Component2 />
activePage === 'xxxxx' && <Component2 />
But as the command list grows bigger and nested command is used frequently, e.g.: 'home > projects > :projectID'
Does someone has a nicer way of doing this?
My solution with react-router-6
<Routes location={`/<current-path>${location}`}> // "current-path refers to the path of the component that contains the current component as a child."
<Route path="/home">
<Route index element={<Home setPage={setPage} />}></Route>
<Route path="prompts">
<Route index element={<Prompts setPage={setPage} />}></Route>
<Route path=":type" element={<div>type</div>}></Route>
</Route>
<Route path="projects" element={<Projects2 />} />
</Route>
</Routes>
Hey @ZhangHanwen96, I made a small API to work with pages and breadcrumbs in cmdk
. Hope it helps