Repository navigation
fix: 3 path/route-resolution bugs surfaced when deploying with 0.5.0 - #59
Merged
Merged
Conversation
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.
Hi again! I've been deploying Docusaurus sites with the new 0.5.0 release and ran into a
few cases where
generateMarkdownFileswrites/links a.mdfile to a path that doesn'tmatch where Docusaurus actually serves the page — so the link 404s. Here are the fixes I
propose. All three are internal-only (no API changes) and independent, so they can be
reviewed separately.
1.
baseUrlbaked into the physical file pathProblem. With a non-root
baseUrl(e.g./some/subpath/), the file path is derivedfrom the absolute
doc.url, which already includesbaseUrl. Docusaurus writes its ownHTML output without
baseUrl(the host mounts it), so the generated.mdlands onelevel too deep and
baseUrlis effectively applied twice.Solution. Strip the
siteUrlbaseUrlsegment from the pathname before deriving thephysical path.
Root
baseUrl: '/'is unaffected.2. Compound number prefixes not fully stripped
Problem. Ordering prefixes were stripped with
/^\d+-/(a single dash only). Aversion-like folder such as
03--1.6.X(prefix03-+ name-1.6.X) became-1.6.Xinstead of
1.6.X, so route matching missed and the file was written under anon-existent
-1.6.X/directory.Solution. Mirror Docusaurus's
DefaultNumberPrefixParser(one-or-more[-_.]separator, and leave version/date-like names intact).
3. Explicit frontmatter
slug/idoverridden by a coincidental routeProblem.
resolveDocumentUrl()only checked frontmatter after a filename-tailsuffix match. A
slug: "/"root page whose filename tail isintrocould suffix-match anunrelated
/some-section/introroute and steal it — leaving the real root page with noindex.mdand nollms.txtentry, and bumping the other page to a-2suffix.Solution. Check the explicit
slug/id(including theslug: "/"root case) beforethe filename heuristic, so an authoritative declaration always wins.
Documents without a
slug/idare unaffected.Testing
Added regression tests for each fix (baseUrl, compound prefixes, and the slug/id collision
end-to-end) and ran the full suite with no regressions.