facebook / facebook/docusaurus
Early error if a blog post has slug: '/' that would be shadowed by home page
- Dominant language
- TypeScript
- Stars
- 66.2k
- Forks
- 10k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 52
Description
### Have you read the Contributing Guidelines on issues?
- [X] I have read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#reporting-new-issues).
### Prerequisites
- [X] I'm using the latest version of Docusaurus.
- [ ] I have tried the `npm run clear` or `yarn clear` command.
- [X] I have tried `rm -rf node_modules yarn.lock package-lock.json` and re-installing packages.
- [X] I have tried creating a repro with https://new.docusaurus.io.
- [X] I have read the console error message carefully (if applicable).
### Description
A md file with frontmatter with slug of `/` woule generate path as `/blog/` by default.
But actually, `/blog/` would redirect to be `/blog`, i.e. the home page of blogs.
### Steps to reproduce
place a md file under blog dir, i.e. `/blog/test.md`:
```md
---
slug: /
---
# test
```
### Expected behavior
- possible behavior 1: build the project, then we can visit `/blog/` (or `/blog/xxx`), which is rendered from `/blog/test.md`
- possible behavior 2: just refuse or warn the render requirement of slug `/` in the building part, e.g. added the ruler in `joi` in `packages/docusaurus-plugin-content-blog/src/frontMatter.ts:66`.
### Actual behavior
1. `/blog` or `/blog/` all points to the home page of blog
2. but the blog page (containing 5 articles default) would have the right arcticle rendered from `/blog/test.md`
3. if the arcticle with slug of `/` failed to be parsed at the same time (e.g. `
- I do not know well now that the md would be finally rendered, why the render part of `/blog/` should be just skipped ...
### Your environment
- Public source code:
- Public site URL:
- Docusaurus version used:
- Environment name and version (e.g. Chrome 89, Node.js 16.4):
- Operating system and version (e.g. Ubuntu 20.04.2 LTS):
### Self-service
- [X] I'd be willing to fix this bug myself.
Contributor guide
Assessment
This issue has not been assessed yet.