mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
refactor(routing): migrate to directory-based board routing
This commit is contained in:
+31
-28
@@ -8,6 +8,8 @@ import useCreateBoardModalStore from './stores/use-create-board-modal-store';
|
||||
import useSpecialThemeStore from './stores/use-special-theme-store';
|
||||
import useIsMobile from './hooks/use-is-mobile';
|
||||
import useTheme from './hooks/use-theme';
|
||||
import { useDefaultSubplebbits } from './hooks/use-default-subplebbits';
|
||||
import { getSubplebbitAddress } from './lib/utils/route-utils';
|
||||
import styles from './app.module.css';
|
||||
import Board from './views/board';
|
||||
import Catalog from './views/catalog';
|
||||
@@ -27,12 +29,14 @@ import TopBar from './components/topbar';
|
||||
import SettingsModal from './components/settings-modal';
|
||||
|
||||
const BoardLayout = () => {
|
||||
const { accountCommentIndex, subplebbitAddress } = useParams();
|
||||
const { accountCommentIndex, boardIdentifier } = useParams();
|
||||
const location = useLocation();
|
||||
const isMobile = useIsMobile();
|
||||
const isInAllView = isAllView(location.pathname);
|
||||
const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
|
||||
const isInModView = isModView(location.pathname);
|
||||
const defaultSubplebbits = useDefaultSubplebbits();
|
||||
const subplebbitAddress = boardIdentifier ? getSubplebbitAddress(boardIdentifier, defaultSubplebbits) : undefined;
|
||||
const pendingPost = useAccountComment({ commentIndex: accountCommentIndex ? parseInt(accountCommentIndex) : undefined });
|
||||
const { closeCreateBoardModal } = useCreateBoardModalStore();
|
||||
|
||||
@@ -130,42 +134,41 @@ const App = () => (
|
||||
<Routes>
|
||||
<Route element={<GlobalLayout />}>
|
||||
<Route path='/' element={<Home />} />
|
||||
<Route path='/:tag' element={<Home />} />
|
||||
<Route path='/faq' element={<FAQ />} />
|
||||
<Route path='*' element={<NotFound />} />
|
||||
<Route element={<BoardLayout />}>
|
||||
<Route path='/p/:subplebbitAddress' element={<Board />} />
|
||||
<Route path='/p/:subplebbitAddress/settings' element={<Board />} />
|
||||
<Route path='/p/:subplebbitAddress/catalog' element={<Catalog />} />
|
||||
<Route path='/p/:subplebbitAddress/catalog/settings' element={<Catalog />} />
|
||||
<Route path='/all/:timeFilterName?' element={<Board />} />
|
||||
<Route path='/all/:timeFilterName?/settings' element={<Board />} />
|
||||
<Route path='/all/description' element={<Post />} />
|
||||
<Route path='/all/catalog/:timeFilterName?' element={<Catalog />} />
|
||||
<Route path='/all/catalog/:timeFilterName?/settings' element={<Catalog />} />
|
||||
|
||||
<Route path='/p/:subplebbitAddress/c/:commentCid' element={<Post />} />
|
||||
<Route path='/p/:subplebbitAddress/c/:commentCid/settings' element={<Post />} />
|
||||
<Route path='/p/:subplebbitAddress/description' element={<Post />} />
|
||||
<Route path='/p/:subplebbitAddress/description/settings' element={<Post />} />
|
||||
<Route path='/p/:subplebbitAddress/rules' element={<Post />} />
|
||||
<Route path='/p/:subplebbitAddress/rules/settings' element={<Post />} />
|
||||
<Route path='/subscriptions/:timeFilterName?' element={<Board />} />
|
||||
<Route path='/subscriptions/:timeFilterName?/settings' element={<Board />} />
|
||||
<Route path='/subscriptions/catalog/:timeFilterName?' element={<Catalog />} />
|
||||
<Route path='/subscriptions/catalog/:timeFilterName?/settings' element={<Catalog />} />
|
||||
|
||||
<Route path='/p/all/:timeFilterName?' element={<Board />} />
|
||||
<Route path='/p/all/:timeFilterName?/settings' element={<Board />} />
|
||||
<Route path='/p/all/description' element={<Post />} />
|
||||
<Route path='/p/all/catalog/:timeFilterName?' element={<Catalog />} />
|
||||
<Route path='/p/all/catalog/:timeFilterName?/settings' element={<Catalog />} />
|
||||
<Route path='/mod/:timeFilterName?' element={<Board />} />
|
||||
<Route path='/mod/:timeFilterName?/settings' element={<Board />} />
|
||||
<Route path='/mod/catalog/:timeFilterName?' element={<Catalog />} />
|
||||
<Route path='/mod/catalog/:timeFilterName?/settings' element={<Catalog />} />
|
||||
|
||||
<Route path='/p/subscriptions/:timeFilterName?' element={<Board />} />
|
||||
<Route path='/p/subscriptions/:timeFilterName?/settings' element={<Board />} />
|
||||
<Route path='/p/subscriptions/catalog/:timeFilterName?' element={<Catalog />} />
|
||||
<Route path='/p/subscriptions/catalog/:timeFilterName?/settings' element={<Catalog />} />
|
||||
<Route path='/pending/:accountCommentIndex' element={<PendingPost />} />
|
||||
<Route path='/pending/:accountCommentIndex/settings' element={<PendingPost />} />
|
||||
|
||||
<Route path='/p/mod/:timeFilterName?' element={<Board />} />
|
||||
<Route path='/p/mod/:timeFilterName?/settings' element={<Board />} />
|
||||
<Route path='/p/mod/catalog/:timeFilterName?' element={<Catalog />} />
|
||||
<Route path='/p/mod/catalog/:timeFilterName?/settings' element={<Catalog />} />
|
||||
<Route path='/:boardIdentifier' element={<Board />} />
|
||||
<Route path='/:boardIdentifier/settings' element={<Board />} />
|
||||
<Route path='/:boardIdentifier/catalog' element={<Catalog />} />
|
||||
<Route path='/:boardIdentifier/catalog/settings' element={<Catalog />} />
|
||||
|
||||
<Route path='/profile/:accountCommentIndex' element={<PendingPost />} />
|
||||
<Route path='/profile/:accountCommentIndex/settings' element={<PendingPost />} />
|
||||
<Route path='/:boardIdentifier/thread/:commentCid' element={<Post />} />
|
||||
<Route path='/:boardIdentifier/thread/:commentCid/settings' element={<Post />} />
|
||||
<Route path='/:boardIdentifier/description' element={<Post />} />
|
||||
<Route path='/:boardIdentifier/description/settings' element={<Post />} />
|
||||
<Route path='/:boardIdentifier/rules' element={<Post />} />
|
||||
<Route path='/:boardIdentifier/rules/settings' element={<Post />} />
|
||||
</Route>
|
||||
<Route path='/not-found' element={<NotFound />} />
|
||||
<Route path='*' element={<NotFound />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user