facebook / facebook/docusaurus

Early error if a blog post has slug: '/' that would be shadowed by home page

Đang mở
#7,870 7 bình luận 0 reaction 0 người được giao Xem trên GitHub
feature
Ngôn ngữ chính
TypeScript
Star
66.2k
Fork
10k
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
52

Mô tả

### 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. `

xxx
` is invalid since the valid jsx grammar is `style={{color: "red"}}`.), then the build engine would not report the error directly from this arcticle, but from the page(containing of 5 arcticles defualt), which is very confusing to the developers (e.g. me).
- 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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.