fix: resolve slug conflict when index/README and dirname file coexist#11910
Open
Vedthakar wants to merge 1 commit intofacebook:mainfrom
Open
fix: resolve slug conflict when index/README and dirname file coexist#11910Vedthakar wants to merge 1 commit intofacebook:mainfrom
Vedthakar wants to merge 1 commit intofacebook:mainfrom
Conversation
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Pre-flight checklist
Motivation
Closes #8555.
This PR fixes a slug conflict in the docs plugin when multiple files in the same directory are recognized as category indexes and would otherwise resolve to the same permalink.
The concrete bug reported in #8555 is:
docs/demo/index.mddocs/demo/demo.mdxBoth currently map to
/docs/demo/, which makes one of them inaccessible. The same conflict can also happen withREADME.mdand a file matching the directory name.This change applies a priority order for category-index-style docs:
indexREADME<dirname>If a lower-priority file loses the conflict, it is reassigned a regular non-category-index slug so that both docs remain accessible. For example, when
index.mdanddemo.mdxcoexist,index.mdkeeps/demo/anddemo.mdxbecomes/demo/demo.For conflicts that still cannot be resolved automatically, the loader now throws a clear duplicate permalink error and points users toward using explicit
slugfront matter.This keeps the fix narrowly scoped to permalink resolution, uses existing docs-plugin/category-index utilities instead of hardcoded filename logic, and preserves current behavior everywhere else.
Test Plan
I added focused tests in
loadVersion.test.tswith a dedicated fixture site covering the new conflict resolution behavior.Verified locally:
docusaurus-plugin-content-docstest suite passesCommands used:
yarn jest packages/docusaurus-plugin-content-docs/src/versions/__tests__/loadVersion.test.ts --testNamePattern="slug conflict" yarn jest packages/docusaurus-plugin-content-docs yarn tsc -p packages/docusaurus-plugin-content-docs/tsconfig.json --noEmitCloses #8555
Also related to: