Files
Goldebek/src/lib/navigation.ts
T
Per Hoener 9714c175e5
Deploy / deploy-master (push) Skipped
Deploy / deploy-dev (push) Successful in 12s
Deploy / app-quality (push) Successful in 1m8s
Deploy / secret-scan (push) Successful in 4s
Deploy / security-deps (push) Successful in 6s
Deploy / app-image (push) Successful in 1m1s
Deploy / validate-dispatch (push) Successful in 1s
Deploy / scheduled-rebuild-dev (push) Skipped
Deploy / scheduled-rebuild-master (push) Skipped
Deploy / rollback-dev (push) Skipped
Deploy / rollback-master (push) Skipped
Deploy / changes (push) Successful in 3s
Deploy / context (push) Successful in 1s
Improve site navigation structure
2026-09-20 13:44:20 +02:00

24 lines
727 B
TypeScript

import navigation from "../../data/navigation.json";
export type NavigationItem = {
href: string;
label: string;
};
export type NavigationGroup = NavigationItem & {
children: readonly NavigationItem[];
};
export const directNavigationItems = navigation.direct satisfies NavigationItem[];
export const navigationGroups = navigation.groups satisfies NavigationGroup[];
export function isNavigationItemActive(pathname: string, href: string) {
return pathname === href || pathname.startsWith(`${href}/`);
}
export function findNavigationGroup(pathname: string) {
return navigationGroups.find((group) =>
isNavigationItemActive(pathname, group.href) || group.children.some((item) => item.href === pathname)
);
}