-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouting.js
40 lines (35 loc) · 1.05 KB
/
routing.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { createBrowserRouter } from "react-router-dom";
import { categories } from "./data/categories";
import App from "./App/App";
import ErrorPage from "./components/ErrorPage/ErrorPage";
import PostDetail from "./features/postContent/PostDetail";
import PostListing from "./features/postListings/PostListing";
export const categoryListingRoutes = categories.map(category => {
return {
path: "categories/" + category.path,
element: <PostListing name={category.name} />,
}
});
// https://reactrouter.com/en/main/routers/create-browser-router
export const router = createBrowserRouter([
{
path: "/",
element: <App />,
errorElement: <ErrorPage />,
children: [
{
path: "",
element: <PostListing name="All" gridArea="main" />,
},
{
path: "search",
element: <PostListing name="Search Results" search={true} gridArea="main" />,
},
{
path: "r/:subreddit/comments/:id/*",
element: <PostDetail gridArea="main" />,
},
...categoryListingRoutes
],
},
]);