mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-30 22:26:38 +08:00
15 lines
495 B
TypeScript
15 lines
495 B
TypeScript
import { dashboardNavigation } from '@/lib/constants/navigation';
|
|
import type { NavigationItem } from '@/types/navigation';
|
|
|
|
export function isPathActive(pathname: string, href: string) {
|
|
if (href === '/') {
|
|
return pathname === '/';
|
|
}
|
|
|
|
return pathname === href || pathname.startsWith(`${href}/`);
|
|
}
|
|
|
|
export function getCurrentNavigationItem(pathname: string): NavigationItem | undefined {
|
|
return dashboardNavigation.find((item) => isPathActive(pathname, item.href));
|
|
}
|