|
1 | 1 | import { A, type RouteDefinition } from '@solidjs/router'; |
2 | 2 | import { LoginPage } from './modules/auth/pages/login.page'; |
| 3 | +import { getConfig } from './modules/config/config.provider'; |
3 | 4 | import { NOTE_ID_REGEX } from './modules/notes/notes.constants'; |
| 5 | +import { buildViewNotePagePath } from './modules/notes/notes.models'; |
4 | 6 | import { CreateNotePage } from './modules/notes/pages/create-note.page'; |
5 | 7 | import { ViewNotePage } from './modules/notes/pages/view-note.page'; |
6 | 8 | import { Button } from './modules/ui/components/button'; |
7 | 9 | import { AppLayout } from './modules/ui/layouts/app.layout'; |
8 | 10 |
|
9 | | -export const routes: RouteDefinition[] = [ |
10 | | - { |
11 | | - path: '/', |
12 | | - component: AppLayout, |
13 | | - children: [ |
| 11 | +export function getRoutes(): RouteDefinition[] { |
| 12 | + const config = getConfig(); |
| 13 | + const viewNotePath = buildViewNotePagePath({ prefix: config.viewNotePathPrefix }); |
14 | 14 |
|
15 | | - { |
16 | | - path: '/', |
17 | | - component: CreateNotePage, |
18 | | - }, |
19 | | - { |
20 | | - path: '/:noteId', |
21 | | - component: ViewNotePage, |
22 | | - matchFilters: { |
23 | | - noteId: NOTE_ID_REGEX, |
| 15 | + return [ |
| 16 | + { |
| 17 | + path: '/', |
| 18 | + component: AppLayout, |
| 19 | + children: [ |
| 20 | + |
| 21 | + { |
| 22 | + path: '/', |
| 23 | + component: CreateNotePage, |
| 24 | + }, |
| 25 | + { |
| 26 | + path: viewNotePath, |
| 27 | + component: ViewNotePage, |
| 28 | + matchFilters: { |
| 29 | + noteId: NOTE_ID_REGEX, |
| 30 | + }, |
| 31 | + }, |
| 32 | + { |
| 33 | + path: '*404', |
| 34 | + component: () => ( |
| 35 | + <div class="flex flex-col items-center justify-center mt-6"> |
| 36 | + <div class="text-3xl font-light text-muted-foreground">404</div> |
| 37 | + <h1 class="font-semibold text-lg my-2">Page Not Found</h1> |
| 38 | + <p class="text-muted-foreground">The page you are looking for does not exist.</p> |
| 39 | + <p class="text-muted-foreground">Please check the URL and try again.</p> |
| 40 | + <Button as={A} href="/" class="mt-4" variant="secondary"> |
| 41 | + <div class="i-tabler-arrow-left mr-2"></div> |
| 42 | + Go back home |
| 43 | + </Button> |
| 44 | + </div> |
| 45 | + ), |
24 | 46 | }, |
25 | | - }, |
26 | | - { |
27 | | - path: '*404', |
28 | | - component: () => ( |
29 | | - <div class="flex flex-col items-center justify-center mt-6"> |
30 | | - <div class="text-3xl font-light text-muted-foreground">404</div> |
31 | | - <h1 class="font-semibold text-lg my-2">Page Not Found</h1> |
32 | | - <p class="text-muted-foreground">The page you are looking for does not exist.</p> |
33 | | - <p class="text-muted-foreground">Please check the URL and try again.</p> |
34 | | - <Button as={A} href="/" class="mt-4" variant="secondary"> |
35 | | - <div class="i-tabler-arrow-left mr-2"></div> |
36 | | - Go back home |
37 | | - </Button> |
38 | | - </div> |
39 | | - ), |
40 | | - }, |
41 | | - ], |
42 | | - }, |
43 | | - { |
44 | | - path: '/login', |
45 | | - component: LoginPage, |
46 | | - }, |
47 | | -]; |
| 47 | + ], |
| 48 | + }, |
| 49 | + { |
| 50 | + path: '/login', |
| 51 | + component: LoginPage, |
| 52 | + }, |
| 53 | + ]; |
| 54 | +} |
0 commit comments