@@ -27,6 +27,11 @@ interface SidebarLinkProps {
2727 * Indicates that the links are currently hidden. Overriden by isActive
2828 */
2929 collapsed ?: boolean | null ;
30+
31+ /**
32+ * Whether to show the chevron, if the page has children
33+ */
34+ showChevron ?: boolean ;
3035}
3136
3237export function SidebarLink ( {
@@ -36,6 +41,7 @@ export function SidebarLink({
3641 path,
3742 collapsed = null ,
3843 className = '' ,
44+ showChevron = true ,
3945} : SidebarLinkProps ) {
4046 const isActive = path ?. indexOf ( to ) === 0 ;
4147 const enableSubtree = isActive || collapsed === false ;
@@ -44,10 +50,16 @@ export function SidebarLink({
4450 const [ showSubtree , setShowSubtree ] = useState ( enableSubtree ) ;
4551
4652 return (
47- < li className = { `toc-item ${ className } ` } data-sidebar-branch data-path = { path } >
53+ < li
54+ className = { `toc-item ${ className } ` }
55+ data-sidebar-branch
56+ data-sidebar-branch-has-subtree = { hasSubtree }
57+ data-path = { path }
58+ >
4859 < SidebarNavItem
4960 to = { to }
5061 data-sidebar-link
62+ data-sidebar-link-has-subtree = { hasSubtree }
5163 isActive = { to === getUnversionedPath ( path ) }
5264 onClick = { ( ) => {
5365 // Allow toggling the sidebar subtree only if the item is selected
@@ -57,9 +69,13 @@ export function SidebarLink({
5769 } }
5870 >
5971 { title || children }
60- { hasSubtree && < Chevron direction = { showSubtree ? 'down' : 'right' } /> }
72+ { hasSubtree && showChevron && (
73+ < Chevron direction = { showSubtree ? 'down' : 'right' } />
74+ ) }
6175 </ SidebarNavItem >
62- { title && children && < ul data-sidebar-tree > { showSubtree && children } </ ul > }
76+ { title && children && hasSubtree && (
77+ < ul data-sidebar-tree > { showSubtree && children } </ ul >
78+ ) }
6379 </ li >
6480 ) ;
6581}
0 commit comments