2024-10-23 16:00:53 +00:00
|
|
|
import { createBrowserRouter } from 'react-router-dom'
|
2024-10-31 17:14:45 +00:00
|
|
|
import { NDKContextType } from 'contexts/NDKContext'
|
2024-10-23 16:00:53 +00:00
|
|
|
import { Layout } from 'layout'
|
2024-10-31 17:14:45 +00:00
|
|
|
import { SearchPage } from '../pages/search'
|
2024-07-11 15:09:47 +00:00
|
|
|
import { AboutPage } from '../pages/about'
|
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'
|
2024-09-03 10:13:51 +00:00
|
|
|
import { ModPage } from '../pages/mod'
|
2024-07-11 12:52:48 +00:00
|
|
|
import { ModsPage } from '../pages/mods'
|
2024-09-03 08:05:37 +00:00
|
|
|
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'
|
2024-10-31 17:14:45 +00:00
|
|
|
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'
|
2024-10-31 17:14:45 +00:00
|
|
|
import { writeRouteAction } from '../pages/write/action'
|
2024-10-31 19:14:29 +00:00
|
|
|
import { BlogsPage } from 'pages/blogs'
|
2024-10-31 17:14:45 +00:00
|
|
|
import { BlogPage } from 'pages/blog'
|
2024-10-31 19:14:29 +00:00
|
|
|
import { blogRouteLoader } from 'pages/blog/loader'
|
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',
|
2024-09-18 16:42:50 +00:00
|
|
|
game: '/game/:name',
|
2024-07-11 12:15:03 +00:00
|
|
|
mods: '/mods',
|
2024-09-03 10:13:51 +00:00
|
|
|
mod: '/mod/:naddr',
|
2024-07-11 12:15:03 +00:00
|
|
|
about: '/about',
|
2024-10-31 17:14:45 +00:00
|
|
|
blogs: '/blogs',
|
2024-10-31 19:14:29 +00:00
|
|
|
blog: '/blogs/: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',
|
2024-09-16 07:36:35 +00:00
|
|
|
search: '/search',
|
2024-07-12 13:55:42 +00:00
|
|
|
settingsProfile: '/settings-profile',
|
|
|
|
settingsRelays: '/settings-relays',
|
|
|
|
settingsPreferences: '/settings-preferences',
|
2024-09-03 08:05:37 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-09-18 16:42:50 +00:00
|
|
|
export const getGamePageRoute = (name: string) =>
|
|
|
|
appRoutes.game.replace(':name', name)
|
|
|
|
|
2024-09-03 10:13:51 +00:00
|
|
|
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
|
|
|
|
2024-10-31 17:14:45 +00:00
|
|
|
export const getBlogPageRoute = (eventId: string) =>
|
|
|
|
appRoutes.blog.replace(':naddr', eventId)
|
|
|
|
|
2024-09-03 08:05:37 +00:00
|
|
|
export const getProfilePageRoute = (nprofile: string) =>
|
|
|
|
appRoutes.profile.replace(':nprofile', nprofile)
|
|
|
|
|
2024-10-31 17:14:45 +00:00
|
|
|
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,
|
2024-10-31 19:14:29 +00:00
|
|
|
element: <BlogPage />,
|
|
|
|
loader: blogRouteLoader(context)
|
2024-10-31 17:14:45 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
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 />
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
])
|