Improve site navigation structure
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
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
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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)
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user