import { createPortal } from 'react-dom'; import classNames from 'classnames'; import { usePathname } from 'next/navigation'; import Link from 'next/link'; import styles from './MobileMenu.module.css'; export function MobileMenu({ items = [], onClose, }: { items: any[]; className?: string; onClose: () => void; }): any { const pathname = usePathname(); const Items = ({ items, className }: { items: any[]; className?: string }): any => (
{items.map(({ label, url, children }: { label: string; url: string; children: any[] }) => { const selected = pathname.startsWith(url); return ( <> {label} {children && } ); })}
); return createPortal(
, document.body, ); } export default MobileMenu;