facebook / facebook/docusaurus

Allow manual sidebars to automatically pick up category indexes

Abierto
#8,557 5 comentarios 1 reacción 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.
- [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

I've run into an issue with `index` markdown files and manually managed sidebars.

Expected:

given sidebars.js
```js
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
const sidebars = {
controllerFirmwareSidebar: [
'index',
{
Configuration: [
'Configuration/index',
],
},
],
};
```

Clicking on "Configuration" in the sidebar should automatically show the content of the index file like illustrated in [the official documentation.](https://docusaurus.io/docs/sidebar/autogenerated#category-index-convention)
This works as expected for the top level.

Am I missing something obvious?
Perhaps the documentation is just unclear on how to work with the index files in a manual sidebar context.
From what I can tell, Docusaurus' documentation uses manual sidebars and has no problems following the index.mdx convention.

### Reproducible demo

_No response_

### Steps to reproduce

1. Create a starter docusaurus with the standard steps as seen in the official documentation.
2. Set up a file an folder structure that follows the sidebar config shown above.
3. Click on the `Configuration` in the sidebar.

### Expected behavior

Immediately show the index.mdx content.

### Actual behavior

Expands category and shows `index` in sidebar.

### Your environment

_No response_

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