DocsMenu.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use client';
  2. import Link from '@/components/Link';
  3. import { usePathname } from 'next/navigation';
  4. import { DocsConfigType } from '@/types';
  5. import clsx from 'clsx';
  6. import { docsConfig } from '@/config/docs';
  7. export default function DocsMenu() {
  8. const pathname = usePathname();
  9. return (
  10. <ul role="list" className="docs-menu scrollbar">
  11. {docsConfig.map((item, index) => (
  12. <li className="docs-menu-group" key={index}>
  13. <span className="docs-menu-header">{item.title}</span>
  14. {item.items && (
  15. <div className="docs-menu-submenu">
  16. {item.items.map((page, j) => (
  17. <Link
  18. href={page.href}
  19. className={clsx(
  20. 'docs-menu-item',
  21. pathname === page.href && 'active'
  22. )}
  23. exact
  24. key={j}
  25. >
  26. {page.title}
  27. {page.label && (
  28. <>
  29. <span className="badge badge-primary ml-2">
  30. {page.label}
  31. </span>
  32. </>
  33. )}
  34. </Link>
  35. ))}
  36. </div>
  37. )}
  38. </li>
  39. ))}
  40. </ul>
  41. );
  42. }