facebook / facebook/docusaurus

Unable to avoid prepending of the baseUrl in NavBar items

Abierto
#8,006 5 comentarios 2 reacciones 0 asignados Ver en GitHub
bug
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.
- [X] 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

Using the `prependBaseUrlToHref` property on NavBar items or `pathname:///` inside `href` property directly doesn't prevent the prepending of the project's `baseUrl` value in the final link.

### Reproducible demo

https://stackblitz.com/edit/github-tvsjbv?file=docusaurus.config.js

### Steps to reproduce

1. Set a `baseUrl` in the docusaurus config file other than `/` (example : `/base/`)
2. Set the docusaurus project as **Docs-only** (docs.routeBasePath : `/`, intro.md slug: `/`, remove `src/pages` folder)
3. Add NavBar links that should point to other place in the same domain. Example:
```js
{
href: '/toto', // or 'pathname:///toto'
prependBaseUrlToHref: false,
label: 'Toto',
position: 'left'
}
```
4. In the broswer go `/base` to get the docs intro page.
5. Check the final `href` value of links inside the NavBar.

### Expected behavior

The navbar item links shouldn't have the `baseUrl` prepended on the `href`

```
https://your-docusaurus-test-site.com/toto
```

### Actual behavior

The navbar item links do have the `baseUrl` prepended on the `href`

```
https://your-docusaurus-test-site.com/base/toto
```

### Your environment

- Public source code: https://stackblitz.com/edit/github-tvsjbv?file=docusaurus.config.js
- Public site URL: https://stackblitz.com/edit/github-tvsjbv?file=docusaurus.config.js
- Docusaurus version used: 2.0.1
- Environment name and version (e.g. Chrome 89, Node.js 16.4): Chrome 104
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): Mac OSX 12.1

### Self-service

- [ ] 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.