feat(doc-kit): bump version, use virtualImports#29
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Updates the Learn site’s doc-kit setup to the latest version and shifts navigation/canonical behavior to be driven by a shared template and virtual JSON imports, aligning Learn with nodejs.org site navigation data.
Changes:
- Bump
@node-core/doc-kitto1.3.2and configuretemplatePath+ canonical link rendering. - Introduce build-time
virtualImportsfor#site/navigation.json(from nodejs.org) and#learn/navigation.json(derived from localnavigation.json+ page titles). - Refactor Sidebar/Nav/Footer components to consume the virtual navigation JSON instead of hardcoded/static local data.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| utils/index.mjs | Adds helpers to derive sidebar groupings + i18n population used by virtual imports. |
| template.html | New HTML template including canonical link and updated head tags. |
| package.json | Bumps doc-kit devDependency to 1.3.2. |
| package-lock.json | Lockfile update for doc-kit 1.3.2. |
| navigation.json | Adds local Learn sidebar grouping source (paths per category). |
| doc-kit.config.mjs | Configures template and adds virtualImports for site + learn navigation. |
| components/Sidebar/index.jsx | Switches sidebar groups to #learn/navigation.json virtual import. |
| components/Navigation/index.jsx | Switches top nav items to #site/navigation.json virtual import. |
| components/Footer/index.jsx | Switches footer links/social links to #site/navigation.json virtual import. |
| components/Footer/footer.json | Removes now-redundant local footer navigation JSON. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| '#site/navigation.json': JSON.stringify( | ||
| populateI18n( | ||
| await fetch( | ||
| 'https://raw.githubusercontent.com/nodejs/nodejs.org/refs/heads/main/apps/site/navigation.json' |
There was a problem hiding this comment.
Could this pretty please be a constant?
There was a problem hiding this comment.
Why we adding a navigation.json ref? When we also adding a navigation.json file?
There was a problem hiding this comment.
#site/navigation is for the navbar and footer
#learn/navigation is for the sidebar
There was a problem hiding this comment.
Constant please and inline doc explaining the diff
| ), | ||
| })); | ||
|
|
||
| export const createI18nPopulator = async () => { |
There was a problem hiding this comment.
No, let's not mess with anything i18n here, completely out of scope, please.
There was a problem hiding this comment.
We are fetching the site navigation from https://github.com/nodejs/nodejs.org/blob/main/apps/site/navigation.json, which needs i18n resolved.
There was a problem hiding this comment.
Hard no for this, we shouldn't use the navigation from there NOR use i18n here. These are separate projects, let's not link them. If we ever need to update the Navigation there, we can just open a PR updating it here too.
There was a problem hiding this comment.
Let's please remove this dependency.
|
|
||
| export const PAGES_DIR = join(import.meta.dirname, '../pages'); | ||
|
|
||
| export const getTitle = async path => { |
There was a problem hiding this comment.
Rather than specifying the title both in the page and the config, we can just get it from the page, no?
There was a problem hiding this comment.
Let's please not. Let's follow what we've been doing already, manually specifying the title, this is supposed to be as static and manual as possible, let's not add automatic magic things.
On nodejs/node sidebar titles !== content title, same on Node.js org, so let's also manually define them here 🙇
MattIPv4
left a comment
There was a problem hiding this comment.
👀 https://nodejs-learn-git-doc-kit-improvements-openjs.vercel.app/learn/ has a canonical of <link rel="canonical" href="https://nodejs.org/learn/index">, that isn't right.
|
Okay, I need to fix In the meantime, fixed Vercel config for more relative URL issues |
Signed-off-by: Aviv Keller <me@aviv.sh>
|
See: nodejs/doc-kit#751 |
There was a problem hiding this comment.
Why are these pages special? Not sure I'm a fan of having complex redirect rules like this?
There was a problem hiding this comment.
Nor am I, we can remove them after nodejs/doc-kit#751. These pages are all /index.html, and need the forward slash until we stop using relative URLs in 751.
There was a problem hiding this comment.
Why are they /index.html pages though? Why aren't they being generated as <path>.html like all our other pages?
Absolute URL support fixes this, sure, but doesn't actually address why these are being generated differently from all the other pages?
There was a problem hiding this comment.
They aren't generated differently, they are written as index.md pages in the source content, for instance https://github.com/nodejs/learn/blob/main/pages/diagnostics/memory/index.md
There was a problem hiding this comment.
That seems like something doc-kit should be able to handle then, and update its imports based on the fact that it knows it has generated an index instead of a path?
Updates doc-kit to the latest version, adding support for:
<link rel="canonical" href="https://nodejs.org/learn{path}" />) (cc @MattIPv4)virtualImports(cc @ovflowd)