Repository navigation
feat: restore previous and next article navigation - #150
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
👋 Codeowner Review RequestThe following codeowners have been identified for the changed files: Team reviewers: @nodejs/nodejs-website Please review the changes when you have a chance. Thank you! 🙏 |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation matches sidebar leaf ordering and includes comprehensive end-to-end coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Restores previous/next navigation beneath Learn articles using sidebar ordering.
Changes:
- Adds recursive article ordering and cross-links.
- Supports responsive layouts and mobile placeholders.
- Adds end-to-end navigation coverage.
| File | Description |
|---|---|
components/ArticleNavigation/index.jsx |
Implements article cross-links. |
components/ArticleNavigation/index.module.css |
Adds responsive styling. |
components/Layout/index.jsx |
Renders navigation below article content. |
tests/e2e/interactions.spec.mjs |
Tests ordering, boundaries, nesting, and mobile navigation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@dcavalcante apologies for the delay here to review it. Out of curiosity, what happens if we don't use this custom layout? Is there a reason we should keep using it? (cc @avivkeller) |
Yeah, I looked into that as well.. but removing the I think we could potentially move those components to the individual doc-kit theme slots and go back to the default Layout, which would also let us use |
Im unsure if prev/next links should be theme slots 🤔 (wdyt @avivkeller?) |
|
Feel free to think of a long-term solution, @dcavalcante. I'll merge your PR for now. Appreciate your contribution! |
|
Thanks for merging @ovflowd! Just to clarify, I wasn't suggesting making prev/next links separate theme slots. They're already handled by doc-kit's default Layout through There are a few compatibility details to work through first, particularly analytics, component props, and nested sidebar navigation. I'll investigate those separately and see whether there's a clean way to get there.. |
Description
Restores previous and next article navigation at the bottom of Learn articles.
On smaller screens, the sidebar is replaced by a navigation dropdown near the top of the page. After reading a long article, continuing to the next article currently requires scrolling back to the top. This adds the same sequential navigation at the end of the article.
The links reuse the existing
BaseCrossLinkcomponent and follow the same article order as the sidebar navigation.Background
Previous/next navigation has existed in earlier versions of the Learn experience.
nodejs/doc-kit#928 identified the absence of previous/next links on Node.js Learn after the doc-kit migration as a regression.
Support was subsequently added to doc-kit in nodejs/doc-kit#1012, which introduced opt-in cross-links through navigation.showCrossLinks.
Learn currently overrides doc-kit's default #theme/Layout, so the cross-link rendering provided by doc-kit's default layout is not used.
There is also earlier history for Learn-specific previous/next navigation:
nodejs/nodejs.org#5242 discussed migrating the old pagination component as a Learn-specific PreviousNextLink.
nodejs/nodejs.org#5331 implemented that component.
nodejs/nodejs.org#5705 removed it temporarily while the new website design was being introduced.
nodejs/nodejs.org#5761 and nodejs/nodejs.org#5781 introduced the redesigned CrossLink component that this change now reuses.
Implementation
ArticleNavigationcomponent beneath article content.BaseCrossLinkfor the existing Previous/Next design.site.jsonas the navigation source of truth.The recursive flattening is intentional because Learn contains nested sidebar sections such as Diagnostics and Node-API.
Validation
Added Playwright coverage for:
Locally verified with:
All 20 end-to-end tests pass.