Skip to content

fix(docs): resolve relative doc links to absolute routes on nav-alias pages - #488

Merged
hivecommons-hive[bot] merged 1 commit into
mainfrom
scanner/fix-487
Oct 26, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
mainfrom
scanner/fix-487

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

📌 Fixes

Closes #487

📝 Summary of Changes

  • Added rewriteRelativeDocLinks (src/lib/rewriteDocLinks.ts), which resolves relative .md/.mdx/extensionless links against the source file's directory into root-absolute /docs/... routes (fragments, queries and CommonMark titles preserved; fenced/inline code, assets, external and absolute links untouched).
  • Wired into buildContent right after rewriteImagePaths, sharing a sourceBaseDir helper.
  • Unit tests and a changelog fragment.

Reproduction (live): /docs/hive/operations/governor renders href="architecture", which the browser resolves to /docs/hive/operations/architecture → 404 (real page: /docs/hive/architecture).

Validation

CI (vitest, TypeScript & ESLint, lint-and-build)

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

… pages do not 404

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Oct 26, 2026

Copy link
Copy Markdown

❌ Deploy Preview for hivecommons-docs failed. Why did it fail? →

Name Link
🔨 Latest commit 3162d79
🔍 Latest deploy log https://app.netlify.com/projects/hivecommons-docs/deploys/6adf8537d583dbc9d031fde5

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending — sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 26, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read the tree, not just the diff — this looks correct to me.

Route mapping holds. getProjectFromSlug (src/app/docs/[...slug]/page.tsx:267-278) strips the project segment, so a rewritten /docs/hive/architecture becomes docSlug=['architecture'] with contentPath=docs/content/hive and hits the direct-file lookup at page.tsx:185-197 before the routeMap fallback. sourceBaseDir (page.tsx:223-234) gives hive for governor.md reached via the operations/governor alias, so architecture.md → /docs/hive/architecture — the exact repro in #487.

Verified against the real content. I ran rewriteRelativeDocLinks over every .md/.mdx under docs/content/ with the same baseDir the page computes: 5 files change, 29 link targets are rewritten, and all 29 resolve to an existing file under docs/content/ (hive/governor.md, agent-definition-yaml.md, agent-terminal.md, variable-substitution.md, macos.md). Nothing with a scheme, a leading /, an asset extension, or inside backticks was touched.

Non-blocking notes:

  • [![badge](img.png)](target.md)-style links (image inside the label) are skipped by the \[([^\]]*)\] label pattern (src/lib/rewriteDocLinks.ts:61). None exist in the tree today, so no action needed; just noting the limit.
  • The red Netlify checks are the known deploy-preview quota exhaustion (docs#419), not this change; Check internal doc links, vitest, and lint-and-build are all green.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read against the tree at main; this looks correct to me.

Route shape matches. The rewriter emits /docs/<dir-relative-to-docs/content>/<name>. That is exactly what the resolver serves: getProjectFromSlug (page.tsx:263-273) peels the project segment and getPageContent (page.tsx:184-196) does a direct docs/content/<project>/<path>.md lookup; general-section files (community/…) fall through to docsContentPath the same way. With dynamicParams = false (page.tsx:107) the only routes that exist are the ones generateStaticParams enumerates, and collectParams(docsContentPath) (page.tsx:393-405) adds every .md/.mdx file at precisely that path — so no rewritten link can target a route that is not pre-rendered.

Scope check against the content. Grepped docs/content for the forms the regex deliberately does not handle: linked images ([![…](img)](x.md)), raw <a href="relative">, and extensionless targets containing a dot (which ANY_EXT would treat as an asset). None exist today, so those gaps are theoretical rather than regressions.

Ordering. Inserted after rewriteImagePaths and before removeCommentPatterns/sanitizeHtmlForMdx (page.tsx:247-250), mirroring the image rewrite; replaceTemplateVariables has already run, so templated destinations are resolved first.

The red checks are all Netlify (deploy-preview, header/redirect/pages rules) — the Free-team quota exhaustion already ruled on in #419, not this diff. Unit tests, TS/ESLint, lint-and-build and the internal link check are green.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit 60c43b0 into main Oct 26, 2026
7 of 12 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-487 branch October 26, 2026 17:00
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#4883162d79` sha256:51cbd3000c5d70d847d28ece88c174d9f589230d16e8c92ea3cd652d7017254f — download from the dashboard or `hivectl review evidence #488`.

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 26, 2026
hivecommons-hive Bot added a commit that referenced this pull request Oct 27, 2026
…#492)

getProjectFromPath's /docs/crux arm (added in #490) and rewriteDocLinks'
reference-style definition fallbacks (added in #488) were the only lines
and branches left unexecuted in those two files.

Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Co-authored-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off dco-signoff: yes size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] Relative doc links 404 when a page is viewed at its nav-alias route

0 participants