11import { useRouter } from 'next/router'
2- import { useState } from 'react'
32import cx from 'classnames'
43import { ActionList , Heading } from '@primer/components'
54
6- import { ChevronDownIcon , ZapIcon , InfoIcon , ShieldLockIcon } from '@primer/octicons-react'
5+ import { ZapIcon , InfoIcon , ShieldLockIcon } from '@primer/octicons-react'
76import { Callout } from 'components/ui/Callout'
87
98import { Link } from 'components/Link'
@@ -61,9 +60,8 @@ export const ArticlePage = () => {
6160 } = useArticleContext ( )
6261 const { t } = useTranslation ( 'pages' )
6362 const currentPath = router . asPath . split ( '?' ) [ 0 ]
64- const [ isActive , setActive ] = useState ( - 1 )
6563
66- const renderTocItem = ( item : MiniTocItem , index : number ) => {
64+ const renderTocItem = ( item : MiniTocItem ) => {
6765 return (
6866 < ActionList . Item
6967 as = "li"
@@ -72,19 +70,9 @@ export const ArticlePage = () => {
7270 sx = { { listStyle : 'none' , padding : '2px' } }
7371 >
7472 < div className = { cx ( 'lh-condensed d-block width-full' ) } >
75- < div className = "d-inline-flex" dangerouslySetInnerHTML = { { __html : item . contents } } />
76- { item . items && item . items . length > 0 && (
77- < button
78- className = "color-bg-default border-0 ml-1"
79- onClick = { ( ) => setActive ( index === isActive ? - 1 : index ) }
80- >
81- { < ChevronDownIcon /> }
82- </ button >
83- ) }
73+ < div dangerouslySetInnerHTML = { { __html : item . contents } } />
8474 { item . items && item . items . length > 0 ? (
85- < ul className = { index === isActive ? 'ml-3' : 'd-none' } >
86- { item . items . map ( renderTocItem ) }
87- </ ul >
75+ < ul className = "ml-3" > { item . items . map ( renderTocItem ) } </ ul >
8876 ) : null }
8977 </ div >
9078 </ ActionList . Item >
@@ -158,7 +146,7 @@ export const ArticlePage = () => {
158146 return {
159147 key : title + i ,
160148 text : title ,
161- renderItem : ( ) => < ul > { renderTocItem ( items , i ) } </ ul > ,
149+ renderItem : ( ) => < ul > { renderTocItem ( items ) } </ ul > ,
162150 }
163151 } ) }
164152 />
0 commit comments