11'use client'
22
33import { type ReactNode , useEffect , useState } from 'react'
4- import type { PageTree } from 'fumadocs-core/server '
4+ import type { Folder , Item , Separator } from 'fumadocs-core/page-tree '
55import { ChevronRight } from 'lucide-react'
66import Link from 'next/link'
77import { usePathname } from 'next/navigation'
@@ -11,7 +11,7 @@ function isActive(url: string, pathname: string, nested = true): boolean {
1111 return url === pathname || ( nested && pathname . startsWith ( `${ url } /` ) )
1212}
1313
14- export function SidebarItem ( { item } : { item : PageTree . Item } ) {
14+ export function SidebarItem ( { item } : { item : Item } ) {
1515 const pathname = usePathname ( )
1616 const active = isActive ( item . url , pathname , false )
1717
@@ -33,15 +33,7 @@ export function SidebarItem({ item }: { item: PageTree.Item }) {
3333 )
3434}
3535
36- export function SidebarFolder ( {
37- item,
38- level,
39- children,
40- } : {
41- item : PageTree . Folder
42- level : number
43- children : ReactNode
44- } ) {
36+ export function SidebarFolder ( { item, children } : { item : Folder ; children : ReactNode } ) {
4537 const pathname = usePathname ( )
4638 const hasActiveChild = checkHasActiveChild ( item , pathname )
4739 const [ open , setOpen ] = useState ( hasActiveChild )
@@ -112,15 +104,15 @@ export function SidebarFolder({
112104 )
113105}
114106
115- export function SidebarSeparator ( { item } : { item : PageTree . Separator } ) {
107+ export function SidebarSeparator ( { item } : { item : Separator } ) {
116108 return (
117109 < p className = 'mt-4 mb-1.5 px-2.5 font-semibold text-[10px] text-gray-500/80 uppercase tracking-wide dark:text-gray-500' >
118110 { item . name }
119111 </ p >
120112 )
121113}
122114
123- function checkHasActiveChild ( node : PageTree . Folder , pathname : string ) : boolean {
115+ function checkHasActiveChild ( node : Folder , pathname : string ) : boolean {
124116 if ( node . index && isActive ( node . index . url , pathname ) ) {
125117 return true
126118 }
0 commit comments