-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashboard,admin-vite-plugin): Add support for outlet routes, loa…
…der, and handle (#11305) **What** - Add support for defining outlet routes using `@`, e.g. `/src/admin/routes/brands/@create/page.tsx` - Add support for exporting a `loader` from a route file. - Add support for exporting a `handle` from a route file. Example usage of a loader and handle: ```tsx // src/admin/routes/articles/[id]/page.tsx import { Button, Container, Heading } from "@medusajs/ui"; import { Link, LoaderFunctionArgs, Outlet, UIMatch, useLoaderData, } from "react-router-dom"; export async function loader({ params }: LoaderFunctionArgs) { const { id } = params; return { id, }; } export const handle = { breadcrumb: (match: UIMatch<{ id: string }>) => { const { id } = match.params; return `#${id}`; }, }; const ProfilePage = () => { const { id } = useLoaderData() as Awaited<ReturnType<typeof loader>>; return ( <div> <Container className="flex justify-between items-center"> <Heading>Article {id}</Heading> <Button size="small" variant="secondary" asChild> <Link to="edit">Edit</Link> </Button> </Container> {/* This will be used for the next example of an Outlet route */} <Outlet /> </div> ); }; export default ProfilePage; ``` In the above example we are passing data to the route from a loader, and defining a breadcrumb using the handle. Example of a outlet route: ```tsx // src/admin/routes/articles/[id]/@edit/page.tsx import { Button, Container, Heading } from "@medusajs/ui"; const ProfileEditPage = () => { return ( <div> {/* Form goes here */} </div> ); }; export default ProfileEditPage; ``` This outlet route will be rendered in the <Outlet /> in the above example when the URL is /articles/1/edit Resolves CMRC-913, CMRC-914, CMRC-915
- Loading branch information
1 parent
c08e6ad
commit a88f657
Showing
6 changed files
with
485 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@medusajs/admin-vite-plugin": patch | ||
"@medusajs/dashboard": patch | ||
--- | ||
|
||
feat(dashboard,admin-vite-plugin): Add support for parallel routes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.