generated from shuding/nextra-docs-template
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix color scheme for mantine * Add static paths and props to endpoint routes * Fix duplicate paths * Fix duplicate paths
- Loading branch information
Showing
23 changed files
with
2,538 additions
and
10,054 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,77 @@ | ||
import { APIEndpoint, APIModule } from '../index'; | ||
import { useRouter } from 'next/router'; | ||
import openapi from '../../data/cosmos-openapi.json'; | ||
import { Flex, Title } from '@mantine/core'; | ||
import { Button } from 'nextra/components'; | ||
import Link from 'next/link'; | ||
import { NextSeo } from 'next-seo'; | ||
import { useData } from 'nextra/data'; | ||
import { filterModuleRoutes } from './utils'; | ||
import { APIEndpoint, APIModule } from '../index'; | ||
import openapi from '../../data/cosmos-openapi.json'; | ||
|
||
export const APIEndpointRoute = () => { | ||
const router = useRouter(); | ||
const routes = router.query.route as string[]; | ||
export const PageTitle = () => { | ||
const { title } = useData(); | ||
return <NextSeo title={title} />; | ||
}; | ||
|
||
if (!routes?.[0]) return null; | ||
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 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 { | ||
paths: uniquePaths, | ||
fallback: false | ||
}; | ||
}; | ||
|
||
const moduleRoutes = filterModuleRoutes(Object.entries(openapi.paths), routes); | ||
export const getStaticProps = async ({ params }) => { | ||
const { route } = params; | ||
const title = `Cosmos API - ${route.join('/')}`; | ||
return { | ||
props: { | ||
ssg: { | ||
route, | ||
title | ||
} | ||
} | ||
}; | ||
}; | ||
|
||
const APIEndpointRoute = () => { | ||
const data = useData(); | ||
if (!data?.route?.length) { | ||
return null; | ||
} | ||
|
||
const { route } = data; | ||
const moduleRoutes = filterModuleRoutes(Object.entries(openapi.paths), route); | ||
const splitRoutes = moduleRoutes?.[0]?.[0].split('/'); | ||
const SEO_TITLE = `Cosmos API - ${splitRoutes?.[2]} - Sei Docs`; | ||
|
||
if (routes.length === 2) { | ||
if (route.length === 2) { | ||
return ( | ||
<Flex direction={'column'} gap='md'> | ||
<NextSeo title={SEO_TITLE}></NextSeo> | ||
|
||
<Link href={`/endpoints/cosmos#${splitRoutes[1]}`}> | ||
<Button>Back</Button> | ||
</Link> | ||
|
||
<Title order={1} mb='xl'> | ||
{routes.join('/')} | ||
{route.join('/')} | ||
</Title> | ||
<APIModule prefix={routes.join('/')} basePaths={moduleRoutes.map((route) => route[0])} /> | ||
<APIModule prefix={route.join('/')} basePaths={moduleRoutes.map((route) => route[0])} /> | ||
</Flex> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<NextSeo title={SEO_TITLE}></NextSeo> | ||
<APIEndpoint endpoint={moduleRoutes[0]} /> | ||
</> | ||
); | ||
return <APIEndpoint endpoint={moduleRoutes[0]} />; | ||
}; | ||
|
||
export default APIEndpointRoute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './APIEndpointRoute'; | ||
export { default as APIEndpointRoute } from './APIEndpointRoute'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,59 @@ | ||
// components/EvmWalletConnect/EvmWalletConnect.tsx | ||
import { | ||
connectorsForWallets, | ||
RainbowKitProvider, | ||
} from "@rainbow-me/rainbowkit"; | ||
import { injectedWallet, metaMaskWallet } from "@rainbow-me/rainbowkit/wallets"; | ||
import { Chain, configureChains, createConfig, WagmiConfig } from "wagmi"; | ||
import { publicProvider } from "wagmi/providers/public"; | ||
import "@rainbow-me/rainbowkit/styles.css"; | ||
import { ChainRpcUrls } from "viem/_types/types/chain"; | ||
import { connectorsForWallets, RainbowKitProvider } from '@rainbow-me/rainbowkit'; | ||
import { injectedWallet, metaMaskWallet } from '@rainbow-me/rainbowkit/wallets'; | ||
import { Chain, configureChains, createConfig, WagmiConfig } from 'wagmi'; | ||
import { publicProvider } from 'wagmi/providers/public'; | ||
import '@rainbow-me/rainbowkit/styles.css'; | ||
import { ChainRpcUrls } from 'viem/_types/types/chain'; | ||
import CustomConnectButton from './CustomConnectButton'; | ||
|
||
export default function EvmWalletConnect() { | ||
const rpcUrl: ChainRpcUrls = { | ||
http: ["https://evm-rpc.sei-apis.com"], | ||
webSocket: ["wss://evm-ws.sei-apis.com"], | ||
}; | ||
const sei: Chain = { | ||
id: 1329, | ||
name: "Sei Network", | ||
network: "Sei", | ||
nativeCurrency: { | ||
decimals: 18, | ||
name: "Sei", | ||
symbol: "SEI", | ||
}, | ||
rpcUrls: { | ||
public: rpcUrl, | ||
default: rpcUrl, | ||
}, | ||
testnet: true, | ||
blockExplorers: { | ||
default: { name: "Seitrace", url: "https://seitrace.com" }, | ||
}, | ||
}; | ||
const rpcUrl: ChainRpcUrls = { | ||
http: ['https://evm-rpc.sei-apis.com'], | ||
webSocket: ['wss://evm-ws.sei-apis.com'] | ||
}; | ||
const sei: Chain = { | ||
id: 1329, | ||
name: 'Sei Network', | ||
network: 'Sei', | ||
nativeCurrency: { | ||
decimals: 18, | ||
name: 'Sei', | ||
symbol: 'SEI' | ||
}, | ||
rpcUrls: { | ||
public: rpcUrl, | ||
default: rpcUrl | ||
}, | ||
testnet: true, | ||
blockExplorers: { | ||
default: { name: 'Seitrace', url: 'https://seitrace.com' } | ||
} | ||
}; | ||
|
||
const { chains, publicClient } = configureChains( | ||
[sei], | ||
[publicProvider()] | ||
); | ||
const { chains, publicClient } = configureChains([sei], [publicProvider()]); | ||
|
||
const projectId = "385413c214cb74213e0679bc30dd4e4c"; | ||
const connectors = connectorsForWallets([ | ||
{ | ||
groupName: "Recommended", | ||
wallets: [ | ||
injectedWallet({ chains }), | ||
metaMaskWallet({ projectId, chains }), | ||
], | ||
}, | ||
]); | ||
const projectId = '385413c214cb74213e0679bc30dd4e4c'; | ||
const connectors = connectorsForWallets([ | ||
{ | ||
groupName: 'Recommended', | ||
wallets: [injectedWallet({ chains }), metaMaskWallet({ projectId, chains })] | ||
} | ||
]); | ||
|
||
const wagmiConfig = createConfig({ | ||
autoConnect: false, | ||
connectors, | ||
publicClient, | ||
}); | ||
const wagmiConfig = createConfig({ | ||
autoConnect: false, | ||
connectors, | ||
publicClient | ||
}); | ||
|
||
return ( | ||
<div className="my-4 flex justify-center"> | ||
<WagmiConfig config={wagmiConfig}> | ||
<RainbowKitProvider chains={chains}> | ||
<CustomConnectButton /> | ||
</RainbowKitProvider> | ||
</WagmiConfig> | ||
</div> | ||
); | ||
return ( | ||
<div className='my-4 flex justify-center'> | ||
<WagmiConfig config={wagmiConfig}> | ||
<RainbowKitProvider chains={chains}> | ||
<CustomConnectButton /> | ||
</RainbowKitProvider> | ||
</WagmiConfig> | ||
</div> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.