Skip to content

fix(flame): warn about docu.json routes that link to missing pages - #464

Merged
gitfromwildan merged 2 commits into
mainfrom
feat/flame-warn-missing-routes
Nov 5, 2026
Merged

gitfromwildan merged 2 commits into
mainfrom
feat/flame-warn-missing-routes

Conversation

@gitfromwildan

@gitfromwildan gitfromwildan commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Why

When a page is renamed or deleted but its entry stays in the routes table of docu.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 routes example in the configuration docs was wrong. It repeated the parent path in child hrefs, 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 way Sublink does: child hrefs are joined onto their parent under the docs prefix, and a link is broken when no MDX source has that slug.
    • noLink sections are skipped, but their items are checked.
    • External links (https:, //, mailto:) are not docs pages and are skipped, and #fragment/?query are stripped. Since 99e51c6 the sidebar links both correctly (see below).
    • In sidebar.context: "separator" mode, context sections are group headers and routes without a context are hidden, so neither is checked. In dropdown mode a top-level section without noLink is a real link and is checked.
    • It only runs when docu.json has a routes table. A scanned sidebar always matches the files.
    • Each path is reported once, with its sidebar trail.
  • Wired into all four entries. build.ts and build.impl.ts run it right after the MDX scan, and server.ts and server.impl.ts run it once at startup. It only warns, and the build still succeeds:
⚠ docu.json "routes" links to 2 page(s) with no source in docs/ — the sidebar link will 404:
    /guide/routing  (Guide › Routing)
    /guide/deployment  (Guide › Deployment)
  Add the page, or fix or remove the entry in docu.json.
  • configuration.mdx.
    • The routes example now uses relative hrefs with a noLink section, like the starter template.
    • New text explains how the full path is built and warns against repeating the parent or /docs prefix.
    • It shows the warning and states what is checked.
    • The href field description is updated.
  • Patch changeset for @docubook/flame.

Verification

  • vitest: 770 tests pass, including 19 new ones in route-check.test.ts and 9 in route-links.test.ts (from 99e51c6):
    • path joining, noLink, linked groups, external links, fragments, the docs root, deduplication, malformed entries;
    • both sidebar modes and the old docs example;
    • the warning text;
    • wiring checks for all four entries.
  • No false positives: a test runs the check on flame's own docu.json and on the starter template against their real docs/, and both report nothing.
  • tsc, oxlint, prettier and test:release-plan are clean. The pre-push hook passed.
  • End to end on Bun and Node, template project:
Case Result
Template as shipped no warning
One page renamed, one deleted 2 entries reported by flame build and flame dev
New docs example, separator and dropdown link /docs/getting-started/introduction.html, no warning
Old docs example, separator link /docs/docs/getting-started/docs/…, 2 entries (headers not counted)
Old docs example, dropdown same link, 3 entries (the section is a link there)
flame's own docs no warning

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 Sublink did not. It joined every href onto the parent path and appended .html. The fix makes the sidebar handle them, so the check and the render agree:

  • utils.ts: hasUrlScheme(), splitPathSuffix() and sidebarLinkHref(). A #fragment or ?query stays after .html, and URLs with a scheme pass through. docsNavHref is not reused, because it leaves paths outside /docs without .html and would break root deployments.
  • Sublink links external entries as written and keeps fragments after .html. Active state uses the bare path.
  • Pagination (flattenRoutes, getRouteMap) skips external entries, drops fragments and lists each page once. The context switcher targets the first docs item.
  • route-check.ts reuses the same helpers, and configuration.mdx documents external URLs and fragments in routes.

Template plus an external entry and /configuration#meta, on Bun and Node in both sidebar modes:

19dd376 99e51c6
External entry /docs/getting-startedhttps:/github.com/acme/docs.html https://github.com/acme/docs
Fragment entry /docs/getting-started/configuration#meta.html /docs/getting-started/configuration.html#meta
Pagination included both broken links docs pages only, each once
Link check on the output broken links none

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.
@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docu Ignored Ignored Preview Nov 5, 2026 12:35pm UTC

pullfrog[bot]
pullfrog Bot previously approved these changes Nov 5, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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 each href onto its parent under the docs prefix, the same way Sublink/Menu build fullHref, and reports links that have no scanned MDX source, along with their sidebar trail. I compared its behavior with Menu.tsx in both modes: separator mode, where context routes become headers via renderBorderItem(item, route.href) and there is a flat fallback when no route has a context, and dropdown mode, where Sublink uses parentHref={basePath}. They match.
  • Wiring. The call is the same in build.ts and build.impl.ts (right after scanMdxFiles(DOCS_DIR)), in server.ts (top-level await is already used in that module), and in server.impl.ts. Bun and the Node/Deno compat paths stay in parity.
  • Docs and changeset. The routes example now uses relative child hrefs plus noLink, 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.ts locally under Node vitest and 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 in cache-key.test.ts and experimental.test.ts.

Top priorities: (1) the external-href and fragment skip noted inline. Nothing else rises above noise.

Pullfrog  | View workflow run | Using 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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() and sidebarLinkHref() are client-safe, with no node:* imports. There is a documented reason not to reuse docsNavHref: it would drop .html for paths outside /docs on root deployments.
  • Updated Sublink to link external entries as written. Docs entries are built from the bare path and keep any ?query/#fragment after .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/getRouteMap now go through routeDocsPath. 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. getFirstItemHref passes over external items and strips fragments, and it falls back to the section's own path.
  • Switched route-check.ts to the shared helpers, so the check and the render cannot disagree again.
  • Added tests. These are route-links.test.ts and a new Sublink case under a deployment path. I ran the three related test files under Node vitest and 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.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@gitfromwildan
gitfromwildan merged commit 081f124 into main Nov 5, 2026
15 checks passed
@gitfromwildan
gitfromwildan deleted the feat/flame-warn-missing-routes branch November 5, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant