Repository navigation
fix(portal): link an external card to the portal's own files under its sub-path - #486
Merged
Merged
Conversation
…s sub-path Fumadocs renders a card marked external as a plain link, which the router never sees, so under a sub-path the template's Agent-Friendly Docs card went to /llms.txt at the host's root and got a 404. The Card override adds the base to the files the portal writes: llms.txt, llms-full.txt, sitemap.xml, api/search.json and the pages' .md copies. robots.txt is left out, since the build writes it only at a domain root. Any other address, and one that already has the base, stays as written. A test reads the routes, so a new file route that the set leaves out fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sohail2721
requested review from
Shield-Jaguar and
saeedjamshaid
as code owners
November 24, 2026 07:17
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a base they start with The `.md` rule claimed a sibling app's `/blog/post.md`, and the "already under the base" check left `/api/search.json` at the host's root when the portal itself lives at `/api/`. The set is now exact membership only. The subpath fixture's index page goes back to `.md`, keeping its inline image covered, and the figures page carries the external cards instead, one of them to `/api/search.json` under `/api/`. The e2e previews on 127.0.0.1 and uses `globalThis.fetch`, so the ESLint global is reverted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vite sets NODE_ENV to production when it is unset, as it is under mocha in CI, so every test after the preview loaded React's production renderer beside the development JSX runtime already loaded, and failed with "dispatcher.getOwner is not a function". The test now sets NODE_ENV itself, so Vite leaves it alone, and restores it once the server closes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
saeedjamshaid
left a comment
Collaborator
There was a problem hiding this comment.
Fixes the default Agent-Friendly Docs card under a path, and I found no regressions. CI is green on all 12 jobs and Sonar reports no issues.
Should fix (tests)
- The e2e's preview server only proves that two files exist, which the suite already checks.
card.test.tsis the third copy of the Vite render setup.- The "left as written" addresses test
externalHref, not the card.
Design (a question)
- An external card reads a
/…link differently from every other link in the portal. - If the list stays, it's a second copy of the one in
prerender-pages.ts.
Outside this PR
- I couldn't find a ticket for the Markdown-link click bug you describe. Could you file one?
…ath, as the router does An external card now reads a `/...` address the way every other link in the portal does: `underBase` puts any root-relative address under the base, and `external` changes only how the card opens. The images in API descriptions share the rule. This drops the list of the portal's own files, a second copy of the prerender's, and covers static files, the `.md` copies and pages opened in a new tab. The template tests share one Vite render helper, the address cases are plain calls on `underBase`, and the e2e drops its preview server, which only proved files the suite already checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Filed the Markdown-link click bug as #487. |
|
saeedjamshaid
approved these changes
Nov 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



A portal hosted under a sub-path, such as a preview at
/p/<id>/oracme.github.io/docs, linked the template's "Agent-Friendly Docs" card to the host's root, where there is no file.What was wrong
The default content links the card like this:
fumadocs-core's
Linkrenders anexternallink as a plain<a target="_blank">and never hands it to the router. The router is what adds the base path. Under/p/abc123/, the card washref="/llms.txt"and got a 404, while the SDKs card beside it was/p/abc123/sdks. At the root of a domain nothing was wrong.The fix
An external card now reads a
/…address the way the rest of the portal does.externalchanges only how the card opens: a plain link, in a new tab.underBaseinlib/base-path.tsputs any root-relative address under the base, as the router does for links. It also leaveshttps://…,//…,mailto:, relative and#addresses as written.components/mdx.tsxuses it for external cards.api-markdown.tsx) use it too, replacing their own copy of the regex.llms.txtand the other generated files, the pages'.mdcopies, files fromstatic/and the/__downloads/zips. It also covers a page opened in a new tab.A change in behavior, under a sub-path only. Under a sub-path, an external card to
/pricingnow leads to/docs/pricing. One written as/docs/llms.txtnow leads to/docs/docs/llms.txt. A Markdown link already behaved this way. To link outside the portal, write a full URL. At the root of a domain nothing changes.Not covered
/llms.txt. Its href is right, because the router adds the base. But the click navigates inside the app and shows the portal's own "Page Not Found" instead of the file, at the root as well. Reloading the page shows the file. It's filed as portal: clicking a Markdown or header link to llms.txt shows Page Not Found until the page is reloaded #487.portal.navigation.linksare not affected: the CLI marks onlyhttp(s)://addresses as external, so the rest go to the router.Checked
A copy of the
subpathfixture with the default cards, built athttps://docs.test/p/abc123and driven in headless Chrome:/llms.txt, 404/p/abc123/llms.txt, 200, new tab/p/abc123/sdks/llms.txt, 200test/portal-template/base-path.test.tschecksunderBase. Root-relative addresses go under the base,/docs/llms.txtincluded, as the router reads it. Every other kind of address is left as written.test/portal-template/card.test.ts(new) renders the real Card override under/docs/. An external card gets the path and still opens a new tab. A card not marked external goes to the router as written.test/helpers/template-render.tsholds the Vite render setup thatcard.test.ts,page-actions.test.tsandauthorization-failure.test.tsnow share.test/e2e/portal-build.test.ts:subpathfixture's figures page links two external cards, to/api/llms.txtand/api/api/search.json. The second address starts like the base and still goes under it./llms.txt.A mocha run with every test file loaded, as CI loads them, filtered to the root and sub-path e2e and the template's tests: 78 passing, including the template's type check.
I did not run the whole suite.
🤖 Generated with Claude Code