@@ -10,6 +10,7 @@ import Head from 'next/head';
1010import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter' ;
1111import { vscDarkPlus } from 'react-syntax-highlighter/dist/cjs/styles/prism' ;
1212import { Layout } from '../../components/Layout' ;
13+ import { useRouter } from 'next/router' ;
1314
1415interface DocsPageProps {
1516 content : string ;
@@ -25,6 +26,14 @@ const NAV_ITEMS = [
2526]
2627
2728export default function DocsIndexPage ( { content, headings } : DocsPageProps ) {
29+ const router = useRouter ( ) ;
30+ const currentPath = ( router . asPath ?? router . pathname ?? '' ) . split ( '?' ) [ 0 ] ;
31+ const linkBaseStyle = {
32+ color : '#0052FF' ,
33+ textDecoration : 'underline' ,
34+ fontWeight : 500 ,
35+ } as const ;
36+
2837 return (
2938 < Layout title = "Base Verify Documentation" >
3039 < Head >
@@ -80,29 +89,38 @@ export default function DocsIndexPage({ content, headings }: DocsPageProps) {
8089 Docs
8190 </ h3 >
8291 < nav >
83- { NAV_ITEMS . map ( ( item ) => (
84- < a
85- key = { item . path }
86- href = { item . path }
87- style = { {
88- display : 'block' ,
89- fontSize : '0.875rem' ,
90- color : item . path === '/docs' ? '#0052FF' : '#666' ,
91- textDecoration : 'none' ,
92- marginBottom : '0.75rem' ,
93- fontWeight : item . path === '/docs' ? '600' : '400' ,
94- transition : 'color 0.2s ease'
95- } }
96- onMouseEnter = { ( e ) => {
97- e . currentTarget . style . color = '#0052FF' ;
98- } }
99- onMouseLeave = { ( e ) => {
100- e . currentTarget . style . color = item . path === '/docs' ? '#0052FF' : '#666' ;
101- } }
102- >
103- { item . label }
104- </ a >
105- ) ) }
92+ { NAV_ITEMS . map ( ( item ) => {
93+ const isActive = currentPath === item . path ;
94+ return (
95+ < button
96+ key = { item . path }
97+ type = "button"
98+ onClick = { ( ) => router . push ( item . path ) }
99+ style = { {
100+ display : 'block' ,
101+ fontSize : '0.875rem' ,
102+ color : isActive ? '#0052FF' : '#666' ,
103+ textDecoration : 'none' ,
104+ marginBottom : '0.75rem' ,
105+ fontWeight : isActive ? '600' : '400' ,
106+ transition : 'color 0.2s ease' ,
107+ background : 'transparent' ,
108+ border : 'none' ,
109+ padding : 0 ,
110+ cursor : 'pointer' ,
111+ textAlign : 'left' ,
112+ } }
113+ onMouseEnter = { ( e ) => {
114+ e . currentTarget . style . color = '#0052FF' ;
115+ } }
116+ onMouseLeave = { ( e ) => {
117+ e . currentTarget . style . color = isActive ? '#0052FF' : '#666' ;
118+ } }
119+ >
120+ { item . label }
121+ </ button >
122+ ) ;
123+ } ) }
106124 </ nav >
107125 </ aside >
108126
@@ -262,18 +280,39 @@ export default function DocsIndexPage({ content, headings }: DocsPageProps) {
262280 { ...props }
263281 />
264282 ) ,
265- a : ( { node, ...props } ) => (
266- < a
267- style = { {
268- color : '#0052FF' ,
269- textDecoration : 'underline' ,
270- fontWeight : '500'
271- } }
272- target = "_blank"
273- rel = "noopener noreferrer"
274- { ...props }
275- />
276- ) ,
283+ a : ( { node, href, children, ...props } ) => {
284+ if ( href ?. startsWith ( '/' ) ) {
285+ return (
286+ < button
287+ type = "button"
288+ onClick = { ( ) => router . push ( href ) }
289+ style = { {
290+ ...linkBaseStyle ,
291+ background : 'transparent' ,
292+ border : 'none' ,
293+ padding : 0 ,
294+ cursor : 'pointer' ,
295+ fontSize : 'inherit' ,
296+ textAlign : 'left' ,
297+ } }
298+ >
299+ { children }
300+ </ button >
301+ ) ;
302+ }
303+
304+ return (
305+ < a
306+ style = { linkBaseStyle }
307+ target = { href ?. startsWith ( '#' ) ? undefined : '_blank' }
308+ rel = { href ?. startsWith ( '#' ) ? undefined : 'noopener noreferrer' }
309+ href = { href }
310+ { ...props }
311+ >
312+ { children }
313+ </ a >
314+ ) ;
315+ } ,
277316 table : ( { node, ...props } ) => (
278317 < div style = { { overflowX : 'auto' , marginBottom : '1.25rem' } } >
279318 < table
0 commit comments