-
-
Notifications
You must be signed in to change notification settings - Fork 135
/
Copy pathAppRouter.tsx
34 lines (30 loc) · 1018 Bytes
/
AppRouter.tsx
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
import { Navigate, Route, Routes } from "react-router-dom";
import App from "@components/App";
import SnippetList from "@components/SnippetList";
import {
defaultCategoryName,
defaultLanguage,
defaultSlugifiedSubLanguageName,
} from "@utils/consts";
import { slugify } from "@utils/slugify";
const AppRouter = () => {
const defaultURLPath = `/${slugify(defaultLanguage.name)}/${slugify(defaultSlugifiedSubLanguageName)}/${slugify(defaultCategoryName)}`;
return (
<Routes>
<Route element={<App />}>
<Route path="/" element={<SnippetList />} />
<Route path="/:languageName" element={<SnippetList />} />
<Route
path="/:languageName/:subLanguageName"
element={<SnippetList />}
/>
<Route
path="/:languageName/:subLanguageName/:categoryName"
element={<SnippetList />}
/>
<Route path="*" element={<Navigate to={defaultURLPath} replace />} />
</Route>
</Routes>
);
};
export default AppRouter;