You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Edit: on a second thought, this just seems like some notion of URL parsing and i am sure such libraries exist already.
Maybe something we can benefit from ts-route side is since we already have more definition than raw strings ("nested"-ness with children prop, various param + names, etc.) we could leverage that for something?
The text was updated successfully, but these errors were encountered:
smblee
changed the title
Determine if child route or not
Determine if child route or not (breadcrumbs + nav)
Jun 24, 2022
const isChildOf = (maybeParentPathname: string, maybeChildPathname: string) => {
// since / is a parent of all pathnames, do explicit matching.
if (maybeParentPathname === '/') {
return maybeParentPathname === maybeChildPathname;
}
return maybeChildPathname.startsWith(maybeParentPathname);
};
using this for now which works (for now) since our nav bar items are all at first level.
For nav/breadcrumb purpose, it would be really nice to reverse check if a given URL is
There's probably edge cases here to consider since breadcrumbs are complicated, but at the least if we can have an utility fn to:
The use case would be for a nav item to determine whether the item should be selected or not.
rough sketch of the contract:
Edit: on a second thought, this just seems like some notion of URL parsing and i am sure such libraries exist already.
Maybe something we can benefit from ts-route side is since we already have more definition than raw strings ("nested"-ness with
children
prop, various param + names, etc.) we could leverage that for something?The text was updated successfully, but these errors were encountered: