Repository navigation
Resolve partial imports using the @site alias and partials directories - #55
Merged
Merged
Conversation
Owner
|
Thanks for getting this together. I'll check it out in a minute, but a quick glance it looks correct. |
This was referenced Aug 18, 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.
Closes #54
Problem
resolvePartialImportsonly recognizes the./_partial.mdxconvention: the import regex requires an underscore in the path, and paths resolve relative to the importing file. Docusaurus sites that keep partials insrc/partials/and import them via the@sitealias (kebab-case filenames, no underscore) never match, so the JSX tag survives unresolved and the partial's content is missing from the generated markdown. Details and a real-world example in #54.Changes (all in
resolvePartialImports).mdx/.mdimport path; the partial-detection decision moves entirely to the filter below./partials/directory as partials, in addition to the existing underscore convention (which is unchanged).@site/alias against the site directory. Docusaurus runs builds from the site dir, soprocess.cwd()is the site root.importlines before splicing. Partials commonly import theme components (@theme/Tabsetc.); once inlined mid-document those lines are no longer at the start of the content, escape the later line-anchoredexcludeImportspass, and leak as literal text (worst case inside numbered lists:1. import Tabs from '@theme/Tabs';).Testing
tests/test-site-alias-partials.js(wired intotest:unit): builds a site-shaped fixture (src/partials/+docs/), imports a partial via@site/src/partials/..., and asserts the tag is resolved, the content is inlined in both block and list context, and no import lines leak.test:unitsuite passes from a clean checkout (npm install && npm run build && npm run test:unit), including the existingtest-partials.js,test-missing-partials.js, andtest-circular-imports.js— the underscore convention behaves exactly as before.@sitepartials): before — 144 pages with unresolved tags; after — 0 unresolved tags, 0 leaked imports, 0 errors.