fix(docs): emit error on slug collision to prevent silent overwriting - #12366
fix(docs): emit error on slug collision to prevent silent overwriting#12366ananikets18 wants to merge 1 commit into
Conversation
|
Hi @ananikets18! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Pre-flight checklist
Motivation
Fixes #8555
When a category directory contains both an
index.mdand a document matching the directory's name (e.g.module/index.mdandmodule/module.mdx), they both map to the exact same slug (/docs/module/) via theisCategoryIndexlogic. Previously, Docusaurus would silently allow this collision, leading to unpredictable routing where the index becomes unreachable.Following the maintainer's suggestion on the issue, this PR implements a hard error that explicitly detects slug collisions. When a collision occurs, the build will now safely crash with a highly descriptive error guiding users to add a
slugfront matter to resolve the conflict.Test Plan
Added a new unit test in
loadVersion.test.tswith a mock fixture (version-with-slug-conflicts) that deliberately reproduces thedemo/index.mdanddemo/demo.mdclash.Verified that compiling this fixture triggers the exact targeted error: