Skip to content

Commit

Permalink
Fix duplicate paths
Browse files Browse the repository at this point in the history
  • Loading branch information
besated committed Sep 19, 2024
1 parent 7626702 commit 71b2bde
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion components/APIEndpoint/APIEndpoint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const APIEndpoint = ({ endpoint }: { endpoint: Endpoint }) => {
<Flex direction='column' gap='xl'>
<Breadcrumbs mt='md'>
<Anchor href={`/endpoints/cosmos#${orgName}`}>endpoints</Anchor>
<Anchor href={`/endpoints/${orgName}/${moduleName}`}>{moduleName}</Anchor>
<Anchor href={`/endpoints/cosmos/api/${orgName}/${moduleName}`}>{moduleName}</Anchor>
</Breadcrumbs>
<Title>{functionName}</Title>
<Flex gap='sm' align='center'>
Expand Down
10 changes: 5 additions & 5 deletions components/APIEndpointRoute/APIEndpointRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ export const PageTitle = () => {

export const getStaticPaths = () => {
// Generate static paths for both the full routes and parent routes
// i.e. for /cosmos/bank/v1beta1/supply, we want the routes:
// 1. cosmos/bank/v1beta1/supply
// 2. cosmos/bank
const routes = Object.keys(openapi.paths).map((p) => {
const route = p.split('/').filter((s) => s);
return route;
});
const paths = routes.flatMap((route) => {
const fullRoute = { params: { route } };
const parentRoutes = [];
for (let i = 1; i < route.length; i++) {
parentRoutes.push({ params: { route: route.slice(0, i) } });
}
return [fullRoute, ...parentRoutes];
const parentRoute = { params: { route: [route[0], route[1]] } };
return [fullRoute, parentRoute];
});
const uniquePaths = Array.from(new Set(paths.map((path) => JSON.stringify(path)))).map((path) => JSON.parse(path));
return {
Expand Down
2 changes: 1 addition & 1 deletion components/APIModule/APIModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { Card } from 'nextra/components';

export const APIModule = ({ basePaths, prefix }: { basePaths: any[]; prefix: string }) => {
return Object.values(basePaths).map((path) => {
return <Card children={null} icon={null} key={path} title={path.replace(`/${prefix}`, '')} href={`/endpoints${path}`} />;
return <Card children={null} icon={null} key={path} title={path.replace(`/${prefix}`, '')} href={`/endpoints/cosmos/api${path}`} />;
});
};
2 changes: 1 addition & 1 deletion components/APIModulePaths/APIModulePaths.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const APIModulePaths = ({ basePaths, prefix }: { basePaths: any[]; prefix
return (
<Cards>
{Object.values(basePaths).map((path) => {
return <Card key={path} title={path} href={`/endpoints/${prefix}/${path}`} icon={null} children={null} />;
return <Card key={path} title={path} href={`/endpoints/cosmos/api/${prefix}/${path}`} icon={null} children={null} />;
})}
</Cards>
);
Expand Down
7 changes: 0 additions & 7 deletions pages/endpoints/[...route].mdx

This file was deleted.

7 changes: 7 additions & 0 deletions pages/endpoints/cosmos/api/[...route].mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { APIEndpointRoute } from '../../../../components';
import { PageTitle } from '../../../../components/APIEndpointRoute/APIEndpointRoute';

<PageTitle />
<APIEndpointRoute />

export { getStaticPaths, getStaticProps } from '../../../../components/APIEndpointRoute/APIEndpointRoute';

0 comments on commit 71b2bde

Please sign in to comment.