degmods.com/src/routes/index.tsx

155 lines
4.0 KiB
TypeScript
Raw Normal View History

2024-10-23 16:00:53 +00:00
import { createBrowserRouter } from 'react-router-dom'
import { NDKContextType } from 'contexts/NDKContext'
2024-10-23 16:00:53 +00:00
import { Layout } from 'layout'
import { SearchPage } from '../pages/search'
2024-07-11 15:09:47 +00:00
import { AboutPage } from '../pages/about'
2024-07-11 13:34:12 +00:00
import { BlogsPage } from '../pages/blogs'
2024-07-11 12:15:03 +00:00
import { GamesPage } from '../pages/games'
2024-07-11 11:45:59 +00:00
import { HomePage } from '../pages/home'
import { ModPage } from '../pages/mod'
2024-07-11 12:52:48 +00:00
import { ModsPage } from '../pages/mods'
import { ProfilePage } from '../pages/profile'
2024-07-12 13:55:42 +00:00
import { SettingsPage } from '../pages/settings'
2024-07-11 20:03:52 +00:00
import { SubmitModPage } from '../pages/submitMod'
import { GamePage } from '../pages/game'
import { NotFoundPage } from '../pages/404'
import { FeedLayout } from '../layout/feed'
import { FeedPage } from '../pages/feed'
import { NotificationsPage } from '../pages/notifications'
2024-07-12 09:22:31 +00:00
import { WritePage } from '../pages/write'
import { writeRouteAction } from '../pages/write/action'
import { BlogPage } from 'pages/blog'
2024-07-11 11:45:59 +00:00
2024-07-11 12:15:03 +00:00
export const appRoutes = {
2024-07-11 11:45:59 +00:00
index: '/',
2024-10-23 15:54:33 +00:00
home: '/',
2024-07-11 12:15:03 +00:00
games: '/games',
game: '/game/:name',
2024-07-11 12:15:03 +00:00
mods: '/mods',
mod: '/mod/:naddr',
2024-07-11 12:15:03 +00:00
about: '/about',
blogs: '/blogs',
blog: '/blog/:naddr',
2024-07-12 09:22:31 +00:00
submitMod: '/submit-mod',
2024-08-26 12:11:33 +00:00
editMod: '/edit-mod/:naddr',
2024-07-12 13:55:42 +00:00
write: '/write',
search: '/search',
2024-07-12 13:55:42 +00:00
settingsProfile: '/settings-profile',
settingsRelays: '/settings-relays',
settingsPreferences: '/settings-preferences',
settingsAdmin: '/settings-admin',
2024-10-23 16:00:53 +00:00
profile: '/profile/:nprofile?',
feed: '/feed',
notifications: '/notifications'
2024-07-11 11:45:59 +00:00
}
export const getGamePageRoute = (name: string) =>
appRoutes.game.replace(':name', name)
export const getModPageRoute = (eventId: string) =>
appRoutes.mod.replace(':naddr', eventId)
2024-07-25 15:05:28 +00:00
2024-08-19 06:41:11 +00:00
export const getModsEditPageRoute = (eventId: string) =>
2024-08-26 12:11:33 +00:00
appRoutes.editMod.replace(':naddr', eventId)
2024-08-19 06:41:11 +00:00
export const getBlogPageRoute = (eventId: string) =>
appRoutes.blog.replace(':naddr', eventId)
export const getProfilePageRoute = (nprofile: string) =>
appRoutes.profile.replace(':nprofile', nprofile)
export const routerWithNdkContext = (context: NDKContextType) =>
createBrowserRouter([
{
element: <Layout />,
children: [
{
path: appRoutes.index,
element: <HomePage />
},
{
path: appRoutes.games,
element: <GamesPage />
},
{
path: appRoutes.game,
element: <GamePage />
},
{
path: appRoutes.mods,
element: <ModsPage />
},
{
path: appRoutes.mod,
element: <ModPage />
},
{
path: appRoutes.about,
element: <AboutPage />
},
{
path: appRoutes.blogs,
element: <BlogsPage />
},
{
path: appRoutes.blog,
element: <BlogPage />
},
{
path: appRoutes.submitMod,
element: <SubmitModPage />
},
{
path: appRoutes.editMod,
element: <SubmitModPage />
},
{
path: appRoutes.write,
element: <WritePage />,
action: writeRouteAction(context)
},
{
path: appRoutes.search,
element: <SearchPage />
},
{
path: appRoutes.settingsProfile,
element: <SettingsPage />
},
{
path: appRoutes.settingsRelays,
element: <SettingsPage />
},
{
path: appRoutes.settingsPreferences,
element: <SettingsPage />
},
{
path: appRoutes.settingsAdmin,
element: <SettingsPage />
},
{
path: appRoutes.profile,
element: <ProfilePage />
},
{
element: <FeedLayout />,
children: [
{
path: appRoutes.feed,
element: <FeedPage />
},
{
path: appRoutes.notifications,
element: <NotificationsPage />
}
]
},
{
path: '*',
element: <NotFoundPage />
}
]
}
])