facebook / facebook/docusaurus

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

Abierto
#7,870 7 comentarios 0 reacciones 0 asignados Ver en GitHub
feature
Lenguaje dominante
TypeScript
Estrellas
66.2k
Forks
10k
Merge medio
1 d 3 h
PR fusionados (30 d)
52

Descripción

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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.