Breadcrumbs with navigation
All checks were successful
Build and deploy website / build (push) Successful in 38s

This commit is contained in:
2025-03-15 15:34:24 +01:00
parent 097850267c
commit 05ef06f95c
4 changed files with 62 additions and 3 deletions

View File

@ -22,6 +22,8 @@ const paths: Set<NavLink> = new Set([
"/uses",
])
const projectPaths: Set<string> = new Set<string>(["homepage", "sb1budget"])
/**
* Defines the localized pathnames for the site.
* The key must be used to navigate to the correct path.
@ -63,3 +65,22 @@ export function resolvePathname(pathname: string): AbsolutePathname {
}
return pathname as AbsolutePathname
}
export function isAbsolutePathname(path: string): path is AbsolutePathname {
return path.startsWith("/")
}
export function isNavLink(path: string): path is NavLink {
if (path.startsWith("/en")) {
path = path.slice(2)
}
if (paths.has(path as NavLink)) {
return true
}
const pathSplit = path.split("/").slice(1)
return (
pathSplit.length === 2 &&
pathSplit[0] === "projects" &&
projectPaths.has(pathSplit[1])
)
}