Repository navigation
fix(flame): warn about docu.json routes that link to missing pages - #464
Conversation
A sidebar entry whose page was renamed or deleted rendered a link that 404s, with no hint at build time. `flame build` and `flame dev` now list every such `routes` entry with its sidebar trail. The build still succeeds. `findMissingRouteTargets()` (route-check.ts, pure) builds each link the way Sublink does: child hrefs are joined onto their parent under the docs prefix. `noLink` sections are skipped but their items are checked. External links and fragments are ignored. In `sidebar.context: "separator"` mode, context sections are headers and routes without a context are hidden, so neither is checked. It only runs when docu.json has a routes table; a scanned sidebar always matches the files. The routes example in configuration.mdx repeated the parent path in child hrefs, which renders links like /docs/docs/getting-started/docs/getting-started/introduction.html. It now uses relative hrefs like the starter template, explains how the path is built, and shows the warning.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
ℹ️ No blocking issues. One low-severity gap is noted inline.
Reviewed changes
Reviewed the new docu.json routes checker, how it is wired into the four flame entries, and the fixes to the configuration docs. I used senior mode because the PR touches the build pipeline, but the change is warn-only and does not change any output. Verdict: READY.
route-check.ts. This is a pure check. It joins eachhrefonto its parent under the docs prefix, the same waySublink/MenubuildfullHref, and reports links that have no scanned MDX source, along with their sidebar trail. I compared its behavior withMenu.tsxin both modes: separator mode, where context routes become headers viarenderBorderItem(item, route.href)and there is a flat fallback when no route has a context, and dropdown mode, whereSublinkusesparentHref={basePath}. They match.- Wiring. The call is the same in
build.tsandbuild.impl.ts(right afterscanMdxFiles(DOCS_DIR)), inserver.ts(top-level await is already used in that module), and inserver.impl.ts. Bun and the Node/Deno compat paths stay in parity. - Docs and changeset. The
routesexample now uses relative childhrefs plusnoLink, which removes the doubled/docs/docs/...link. There is a patch changeset for@docubook/flame. - Tests. I ran the 19 new tests in
route-check.test.tslocally under Nodevitestand they pass. The check also reports nothing on flame's own docs or on the template. The source-text wiring assertions follow the existing pattern incache-key.test.tsandexperimental.test.ts.
Top priorities: (1) the external-href and fragment skip noted inline. Nothing else rises above noise.
claude-opus-5-5 | 𝕏
The route check skipped external URLs and stripped fragments on the assumption that the sidebar handles them, but Sublink did not: it joined every href onto the parent path and appended `.html`. An external entry rendered as `/docs/getting-startedhttps://…html` and `/intro#setup` as `/docs/intro#setup.html`. - utils.ts: `hasUrlScheme()`, `splitPathSuffix()` and `sidebarLinkHref()`, which keeps a `#fragment`/`?query` after `.html` and passes URLs with a scheme through. - Sublink links external entries as written and keeps a fragment or query after `.html`; active state and accordions use the bare path. - route.ts: pagination (`flattenRoutes`, `getRouteMap`) skips external entries, drops fragments and lists each page once. Both take an optional route tree for tests. - Context.tsx: the context switcher targets the first docs item, skipping external entries and fragments. - route-check.ts reuses the same helpers, so the check and the sidebar agree. - configuration.mdx documents external URLs and fragments in routes.
There was a problem hiding this comment.
✅ No new issues found. The external-link and fragment gap from the previous review is fixed in the sidebar itself, and that thread is resolved.
Reviewed changes
I reviewed 99e51c6, which changes the sidebar, pagination and the context switcher so they handle the external and fragment hrefs that the check already skips. I used senior mode because the change affects every rendered sidebar link and the pagination order. Verdict: READY.
- Added URL helpers to
utils.ts.hasUrlScheme(),splitPathSuffix()andsidebarLinkHref()are client-safe, with nonode:*imports. There is a documented reason not to reusedocsNavHref: it would drop.htmlfor paths outside/docson root deployments. - Updated
Sublinkto link external entries as written. Docs entries are built from the bare path and keep any?query/#fragmentafter.html. Active state and the accordion key compare only the bare path. External entries never match the active path, so they cannot turn on highlighting or auto-expand by mistake. - Made pagination skip external entries and drop fragments.
flattenRoutes/getRouteMapnow go throughrouteDocsPath. Each page is listed once, and the first entry for a page keeps its title. Plain trees behave exactly as before. - Changed the context switcher to target the first docs item.
getFirstItemHrefpasses over external items and strips fragments, and it falls back to the section's own path. - Switched
route-check.tsto the shared helpers, so the check and the render cannot disagree again. - Added tests. These are
route-links.test.tsand a newSublinkcase under a deployment path. I ran the three related test files under Nodevitestand all 30 tests pass.
I checked a few cases and none of them is a problem. A javascript: href now passes through, but docu.json comes from the site author, navbar links already pass non-/ hrefs through, and the nonce CSP blocks that navigation. An external entry that has items stays consistent across the sidebar, the check and pagination. When /x and /x#frag are siblings, both are highlighted, which matches the documented rule that a fragment link counts as its page.
claude-opus-5-5 | 𝕏

Why
When a page is renamed or deleted but its entry stays in the
routestable ofdocu.json, the sidebar keeps a link that 404s, and nothing says so at build time. #463 made this more visible: such links used to reach stale HTML, and now that removed pages are pruned they 404 as they should.Building the check also showed that the
routesexample in the configuration docs was wrong. It repeated the parent path in childhrefs, which the sidebar renders as/docs/docs/getting-started/docs/getting-started/introduction.html.Changes
route-check.ts(new, pure).findMissingRouteTargets()builds each link the waySublinkdoes: childhrefs are joined onto their parent under the docs prefix, and a link is broken when no MDX source has that slug.noLinksections are skipped, but their items are checked.https:,//,mailto:) are not docs pages and are skipped, and#fragment/?queryare stripped. Since 99e51c6 the sidebar links both correctly (see below).sidebar.context: "separator"mode, context sections are group headers and routes without a context are hidden, so neither is checked. Indropdownmode a top-level section withoutnoLinkis a real link and is checked.docu.jsonhas aroutestable. A scanned sidebar always matches the files.build.tsandbuild.impl.tsrun it right after the MDX scan, andserver.tsandserver.impl.tsrun it once at startup. It only warns, and the build still succeeds:configuration.mdx.routesexample now uses relativehrefs with anoLinksection, like the starter template./docsprefix.hreffield description is updated.@docubook/flame.Verification
vitest: 770 tests pass, including 19 new ones inroute-check.test.tsand 9 inroute-links.test.ts(from 99e51c6):noLink, linked groups, external links, fragments, the docs root, deduplication, malformed entries;docu.jsonand on the starter template against their realdocs/, and both report nothing.tsc,oxlint,prettierandtest:release-planare clean. The pre-push hook passed.flame buildandflame dev/docs/getting-started/introduction.html, no warning/docs/docs/getting-started/docs/…, 2 entries (headers not counted)Review follow-up (99e51c6)
Pullfrog pointed out that the check skipped external URLs and stripped fragments on the assumption that the sidebar handles them, but
Sublinkdid not. It joined everyhrefonto the parent path and appended.html. The fix makes the sidebar handle them, so the check and the render agree:utils.ts:hasUrlScheme(),splitPathSuffix()andsidebarLinkHref(). A#fragmentor?querystays after.html, and URLs with a scheme pass through.docsNavHrefis not reused, because it leaves paths outside/docswithout.htmland would break root deployments.Sublinklinks external entries as written and keeps fragments after.html. Active state uses the bare path.flattenRoutes,getRouteMap) skips external entries, drops fragments and lists each page once. The context switcher targets the first docs item.route-check.tsreuses the same helpers, andconfiguration.mdxdocuments external URLs and fragments inroutes.Template plus an external entry and
/configuration#meta, on Bun and Node in both sidebar modes:/docs/getting-startedhttps:/github.com/acme/docs.htmlhttps://github.com/acme/docs/docs/getting-started/configuration#meta.html/docs/getting-started/configuration.html#meta