diff --git a/src/components/UI/docs/DocsLinks.tsx b/src/components/UI/docs/DocsLinks.tsx index 14beb534ed..6350316399 100644 --- a/src/components/UI/docs/DocsLinks.tsx +++ b/src/components/UI/docs/DocsLinks.tsx @@ -11,6 +11,7 @@ import { } from '@chakra-ui/react'; import { AddIcon, MinusIcon } from '@chakra-ui/icons'; import NextLink from 'next/link'; +import { useRouter } from 'next/router'; import { LinksList } from './'; @@ -20,62 +21,83 @@ interface Props { navLinks: NavLink[]; } -export const DocsLinks: FC = ({ navLinks }) => ( - - {navLinks.map(({ id, to, items }, idx) => { - return ( - - - {({ isExpanded }) => ( - <> - - = ({ navLinks }) => { + const router = useRouter(); + const { slug } = router.query; + return ( + + {navLinks.map(({ id, to, items }, idx) => { + const split = to?.split('/') + const isActive = slug && split && split[split.length - 1] === slug[slug.length - 1]; + return ( + + + {({ isExpanded }) => ( + <> + - {to ? ( - - - {id} - - - ) : ( - {id} - )} - - - {items && ( - -
- {isExpanded ? ( - - ) : ( - - )} -
+ + {to ? ( + + + + {id} + + + + ) : ( + {id} + )} + + {items && ( + +
+ {isExpanded ? ( + + ) : ( + + )} +
+
+ )} +
+ {items && ( + + + )} - - {items && ( - - - - )} - - )} -
-
- ); - })} -
-); + + )} + + + ); + })} + + ); +} diff --git a/src/components/UI/docs/LinkList.tsx b/src/components/UI/docs/LinkList.tsx index d8c84c72d5..9b121c6f79 100644 --- a/src/components/UI/docs/LinkList.tsx +++ b/src/components/UI/docs/LinkList.tsx @@ -1,6 +1,7 @@ import { FC } from 'react'; import { Link, Stack, Text } from '@chakra-ui/react'; import NextLink from 'next/link'; +import { useRouter } from 'next/router'; import { NavLink } from '../../../types'; @@ -8,28 +9,49 @@ interface LinksListProps { links: NavLink[]; } -export const LinksList: FC = ({ links }) => ( - - {links.map(({ id, to, items }) => { - return to ? ( - - - - - {id} - - - - {items && } - - ) : ( - - - {id} - - {items && } - - ); - })} - -); +export const LinksList: FC = ({ links }) => { + const router = useRouter(); + const { slug } = router.query; + return ( + + {links.map(({ id, to, items }) => { + const split = to?.split('/') + const isActive = slug && split && split[split.length - 1] === slug[slug.length - 1]; + return to ? ( + + + + + {id} + + + + {items && } + + ) : ( + + + {id} + + {items && } + + ); + })} + + ); +}; diff --git a/src/data/documentation-links.yaml b/src/data/documentation-links.yaml index 137b4574d2..f889d4cc6f 100644 --- a/src/data/documentation-links.yaml +++ b/src/data/documentation-links.yaml @@ -1,6 +1,7 @@ - id: Getting started - to: /docs/getting-started items: + - id: Introduction + to: /docs/getting-started - id: Hardware requirements to: /docs/getting-started/hardware-requirements - id: Installing Geth @@ -8,8 +9,9 @@ - id: Consensus clients to: /docs/getting-started/consensus-clients - id: Fundamentals - to: /docs/fundamentals items: + - id: Introduction + to: /docs/fundamentals - id: Node architecture to: /docs/fundamentals/node-architecture - id: Command-line options @@ -35,8 +37,9 @@ - id: Interacting with Geth items: - id: JSON-RPC Server - to: /docs/interacting-with-geth/rpc items: + - id: Introduction + to: /docs/interacting-with-geth/rpc - id: Batch requests to: /docs/interacting-with-geth/rpc/batch - id: GraphQL server @@ -70,8 +73,9 @@ - id: 'JavaScript Console 2: Contracts' to: /docs/interacting-with-geth/javascript-console-contracts - id: Developers - to: /docs/developers items: + - id: Introduction + to: /docs/developers - id: Dapp developers items: - id: Go API @@ -83,8 +87,9 @@ - id: Geth for Mobile to: /docs/developers/dapp-developer/mobile - id: EVM tracing - to: /docs/developers/evm-tracing items: + - id: Introduction + to: /docs/developers/evm-tracing - id: Basic traces to: /docs/developers/evm-tracing/basic-traces - id: Built-in tracers