Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
fix: Nested Folders Feature Routing (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
lyind committed Mar 31, 2023
1 parent 6ae948d commit c4ac63a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 5 additions & 5 deletions packages/core/src/components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ function CollectionSearchRedirect() {
}

function EditEntityRedirect() {
const { name, entryName } = useParams();
return <Navigate to={`/collections/${name}/entries/${entryName}`} />;
const params = useParams();
return <Navigate to={`/collections/${params.name}/entries/${params['*']}`} />;
}

const App = ({
Expand Down Expand Up @@ -199,7 +199,7 @@ const App = ({
element={<EditorRoute collections={collections} newRecord />}
/>
<Route
path="/collections/:name/entries/:slug"
path="/collections/:name/entries/*"
element={<EditorRoute collections={collections} />}
/>
<Route
Expand All @@ -209,14 +209,14 @@ const App = ({
}
/>
<Route
path="/collections/:name/filter/:filterTerm"
path="/collections/:name/filter/*"
element={<CollectionRoute collections={collections} />}
/>
<Route
path="/search/:searchTerm"
element={<CollectionRoute collections={collections} isSearchResults />}
/>
<Route path="/edit/:name/:entryName" element={<EditEntityRedirect />} />
<Route path="/edit/:name/*" element={<EditEntityRedirect />} />
<Route path="/page/:id" element={<Page />} />
<Route element={<NotFoundPage />} />
</Routes>
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/components/Collection/CollectionRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ const CollectionRoute = ({
isSingleSearchResult,
collections,
}: CollectionRouteProps) => {
const { name, searchTerm, filterTerm } = useParams();
const params = useParams();
const { name, searchTerm } = params;
const filterTerm = params['*'];
const collection = useMemo(() => {
if (!name) {
return false;
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/components/Editor/EditorRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ interface EditorRouteProps {
}

const EditorRoute = ({ newRecord = false, collections }: EditorRouteProps) => {
const { name, slug } = useParams();
const params = useParams();
const name = params.name;
const slug = params['*'];
const shouldRedirect = useMemo(() => {
if (!name) {
return false;
Expand Down

0 comments on commit c4ac63a

Please sign in to comment.