docusaurus
docusaurus copied to clipboard
Docs plugin - possible conflict between docs files with similar names
Have you read the Contributing Guidelines on issues?
- [x] I have read the Contributing Guidelines on issues.
Description
Hello, currently the framework is functioning smoothly. However, we've encountered an issue. Once a Markdown document starts with a number, a default URL is generated. For example, if the document names are "8 - aaa - test" and "6 - aaa - hello", there are also differences in the slug within the document. After previewing, the system will recognize them as one document. Has anyone encountered a similar problem and know how to solve it?
Self-service
- [ ] I'd be willing to address this documentation request myself.
Please create a https://docusaurus.new runnable repro using our bug report template.
https://stackblitz.com/edit/github-hju2cjvr?file=docs%2Ftutorial-basics%2F7-aaa-display.md
Thanks, I confirm something weird is happening
Thank you very much for your prompt reply. If this issue is fixed or you have any solutions, please let me know again. Since the local files I have were set up a year ago and may not be the latest version, it will be convenient for me to update my local files. Thank you again.
So, the problem is that both documents within the same directory gets assigned the same id
The logic looks like this:
const baseID: string = frontMatter.id ?? unprefixedFileName;
const id = [computeDirNameIdPrefix(), baseID].filter(Boolean).join('/');
The number prefix is not taken into consideration when computing the document id from its file system location.
To prevent such unexpected conflicts, I will add an error message when this happens and recommend that users provide an explicitly distinct front matter ID.
Really curious though: what's the reason you want to use the same name for both files, and only change the number prefix? Do you have a good use case for this?