tweak `useRouterBasePath`

proto/trying-alternative-approach
KATT 2021-11-19 13:58:49 +01:00
parent e593f61363
commit bb4710a0b8
1 changed files with 4 additions and 4 deletions

View File

@ -16,14 +16,14 @@ import Loader from "@components/Loader";
function useRouterBasePath() {
const router = useRouter();
return useMemo(() => {
const path = router.asPath.split("/");
const path = router.asPath.split("/").filter(Boolean);
// For teams
if (path.length > 3) {
return `${path[1]}/${path[2]}`;
if (path[0] === "team") {
return `${path[0]}/${path[1]}`;
}
return path[1] as string;
return path[0] as string;
}, [router.asPath]);
}