Fix navbar highlight for Organized Content sections #182
No reviewers
Labels
No Label
a11y
Backlog
Blocked
Bug
Content
Dependencies
Design
Feature Request
Good First Issue
In Progress
Performance
Priority - High
Priority - Low
Priority - Medium
Untriaged
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: www/www-new#182
Loading…
Reference in New Issue
No description provided.
Delete Branch "amy-navbar-highlight-fix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Also fixes the navbar highlight for the different Advice sections.
Closes #181
@ -201,7 +211,8 @@ function NavItem(props: NavItemProps) {
const isCurrentPage =
router.pathname === props.route ||
(props.submenu != null &&
router.pathname.startsWith(getMainRoute(props.route)));
What if we do:
That doesn't work because whenever we navigate to anything in the About submenu, all of the other entries in the submenu will also be highlighted blue. (Same for the Resources submenu.)
Side note: I ended up keeping the About Us page at
/about
because I was able to make it work, but let me know if we'd prefer to move it to/about/us
. :)@ -190,3 +205,4 @@
submenu?: {
name: string;
route: string;
hasSubsections?: boolean;
We don't need this anymore, correct?
Oops yes sorry, I'll get rid of it! I had to do some mergey stuff and I must've forgotten to delete this line lol
@ -276,0 +295,4 @@
ancestors: { name: string; route: string }[];
}[];
function dfs(
I think this function should be called something like
collectLeaves
Let's make the signature of this function similar to what reduce takes in. Then we could do
(or something like this)
@ -276,0 +304,4 @@
}
let ret = [] as Leaves;
for (const subEntry of entry.submenu) {
ret = ret.concat(dfs(subEntry, [...ancestors, entry]));
You can use
push
ret.push(...dfs(subEntry, [...ancestors, entry]));
Just some nitpicks, looks good otherwise! :)