✨ Breadcrumbs with navigation
All checks were successful
Build and deploy website / build (push) Successful in 38s
All checks were successful
Build and deploy website / build (push) Successful in 38s
This commit is contained in:
@ -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])
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user