nodejs / nodejs.org

The Node.js® Website
https://nodejs.org
MIT License
6k stars 6.16k forks source link

fix: learn page breadcrumbs where label !== path slug #6729

Closed abizek closed 1 month ago

abizek commented 1 month ago

Description

Uses link = pathname check as a fallback for finding breadcrumbs in the navigation tree where the label does not match the path.

Consider the article "event-loop-timers-and-nexttick" where the label is "The Nodejs Event loop". Breadcrumbs cannot be found in the navigation tree. Of course we can always change the article name to match the label but what about the article "discover-javascript-timers"? Why, there is no problem here! Except there is. The "s" in JavaScript is capitalized. (Shocking, I know. I learned this today). "JavaScript" cannot be written as "java-script" in dash-case. Is it javascript or a script written in Java?

Previously docs should have the same article name and label for the breadcrumbs to work. Now it is not necessary. Unless a deeply nested document structure is adopted. In which case we have to DFS the navigation tree.

These four articles faced this breadcrumb issue:

Validation

Before After
image image

Related Issues

Related to #6679

Check List

vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nodejs-org ✅ Ready (Inspect) Visit Preview May 25, 2024 1:16pm
bmuenzenmeyer commented 1 month ago

fast tracking this bug fix - it's small, tested, and the broken behavior is sorta ugly in a small way

mikeesto commented 1 month ago

This PR seems to offer a (competing/similar?) approach https://github.com/nodejs/nodejs.org/pull/6728

bmuenzenmeyer commented 1 month ago

great catch @mikeesto - i suppose we should compare which is best

abizek commented 1 month ago

I didn't see that, nice catch @mikeesto. IMO, #6728's approach is better.

bmuenzenmeyer commented 1 month ago

@abizek appreciate your understanding here! will be closing this - hope you will continue to find ways to contribute

abizek commented 1 month ago

Hey @bmuenzenmeyer, sorry for the misunderstanding here. The digit regex only fixes the first link - https://nodejs.org/en/learn/getting-started/ecmascript-2015-es6-and-beyond. The other three cannot be fixed by it. I fixed both problems since belonged to the same category.

Let me know what you decide, I can revert just the regex changes in my PR if needed.

bmuenzenmeyer commented 1 month ago

haha yea - it looks like we need to slow down here - thanks 😄

bmuenzenmeyer commented 1 month ago

looking for consensus on this plan:

cc @TenzDelek @abizek @ovflowd @AugustinMauroy @mikeesto

TenzDelek commented 1 month ago

looking for consensus on this plan:

cc @TenzDelek @abizek @ovflowd @AugustinMauroy @mikeesto

+1 from me. Haha, looks like I overlooked the part where nodepath is not path which I believe @abizek cover in this pr. You can close my pr🤝 Overall it was great to learn about unit test thanks to @AugustinMauroy . Will try to contribute another time in future

AugustinMauroy commented 1 month ago

+1 for @TenzDelek pr with mixing both of solution. it's the first to arrive

abizek commented 1 month ago

+1 for applying regex solution from @TenzDelek

ovflowd commented 1 month ago

haha yea - it looks like we need to slow down here - thanks 😄

Yes, we shouldn't fast track this PR, small changes, but that touch a lot of stuff 😅

abizek commented 1 month ago

but that touch a lot of stuff

Does it though? It's only breadcrumbs.

ovflowd commented 1 month ago

but that touch a lot of stuff

Does it though? It's only breadcrumbs.

Yes, it touches the breadcrumbs of every single page. That's my definition of "touching a lot of stuff" 😅

github-actions[bot] commented 1 month ago
Lighthouse Results URL Performance Accessibility Best Practices SEO Report
/en 🟢 92 🟢 100 🟢 100 🟢 91 🔗
/en/about 🟢 99 🟢 100 🟢 100 🟢 91 🔗
/en/about/previous-releases 🟢 99 🟢 100 🟢 100 🟢 92 🔗
/en/download 🟢 94 🟢 100 🟢 100 🟢 91 🔗
/en/blog 🟢 98 🟢 100 🟢 100 🟢 92 🔗
github-actions[bot] commented 1 month ago

Unit Test Coverage Report

Lines Statements Branches Functions
Coverage: 92%
90.67% (593/654) 76.08% (175/230) 94.57% (122/129)

Unit Test Report

Tests Skipped Failures Errors Time
131 0 :zzz: 0 :x: 0 :fire: 5.991s :stopwatch:
abizek commented 1 month ago

@ovflowd gently nudging you in case you missed it 😄 https://github.com/nodejs/nodejs.org/pull/6729#discussion_r1608211020

ovflowd commented 1 month ago

@abizek are you going to make the changes we talked about?

abizek commented 1 month ago

@ovflowd I missed it. Done now. I understood what you said just now. There were too many ands and pluses :sweat_smile:. Pushing now.

ovflowd commented 1 month ago

@abizek can I ask you to do a last double-check on all about/learn pages that the breadcrumbs are working? 🙇

abizek commented 1 month ago

All systems are nominal. We are good to go. :+1: @ovflowd

ovflowd commented 1 month ago

All systems are nominal. We are good to go. 👍 @ovflowd

Beam me up, Scotty!