import type { MenuItem } from "../model/types"; export function getCurrentMenu( menus: MenuItem[], pathname: string, ): MenuItem | null { for (const menu of menus) { if ( menu.urlPath !== "" && (menu.urlPath === pathname || pathname.startsWith(menu.urlPath)) ) { return menu; } if (menu.children) { const child = getCurrentMenu(menu.children, pathname); if (child) return child; } } return null; }