File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -2,19 +2,27 @@ import type { TOCItem } from '@docusaurus/mdx-loader';
22import TOCInline from '@theme/TOCInline' ;
33import { useState } from 'react' ;
44
5- export const TableOfContents = ( { items } : { items : ReadonlyArray < TOCItem > } ) => {
5+ type TableOfContentsProps = {
6+ items : ReadonlyArray < TOCItem > ;
7+ } ;
8+
9+ export const TableOfContents = ( { items } : TableOfContentsProps ) => {
610 const [ isTocExpanded , setIsTocExpanded ] = useState ( false ) ;
711
812 return (
9- < div className = "toc-inline -mt-2" >
13+ < nav aria-label = "Table of contents" className = "toc-inline -mt-2" >
1014 < button
15+ aria-controls = "toc-content"
16+ aria-expanded = { isTocExpanded }
1117 className = "rounded-md border-none px-2 py-1 text-[11px] hover:cursor-pointer"
1218 title = { `${ isTocExpanded ? 'Collapse' : 'Expand' } Table of Contents` }
1319 onClick = { ( ) => setIsTocExpanded ( ( prev ) => ! prev ) }
1420 >
1521 { isTocExpanded ? 'Collapse' : 'Expand' }
1622 </ button >
17- < TOCInline maxHeadingLevel = { isTocExpanded ? 3 : 2 } minHeadingLevel = { 2 } toc = { items } />
18- </ div >
23+ < div id = "toc-content" >
24+ < TOCInline maxHeadingLevel = { isTocExpanded ? 3 : 2 } minHeadingLevel = { 2 } toc = { items } />
25+ </ div >
26+ </ nav >
1927 ) ;
2028} ;
You can’t perform that action at this time.
0 commit comments