facebook / facebook/docusaurus

Allow manual sidebars to automatically pick up category indexes

Offen
#8,557 5 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
feature
Vorherrschende Sprache
TypeScript
Sterne
66.2k
Forks
10k
Ø Merge
1 T. 3 Std.
Gemergte PRs (30 T.)
52

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.