facebook / docusaurus

Easy to maintain open source documentation websites.

Home Page:https://docusaurus.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Index pages cannot be generated with an automatically generated siderbar

cshsoft opened this issue · comments

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

using property as docSidebar: [{type: 'autogenerated', dirName: 'xxx'}], index pages cannot be generated, it's report error :
is not associated with a category. useCurrentSidebarCategory() should only be used on category index pages. how do fixed it

Reproducible demo

No response

Steps to reproduce

1: set sidebars as autogenerated
2: add index.mdx in doc dir

Expected behavior

Automatically generate index pages based on category.json

Actual behavior

Index pages cannot be generated with an automatically generated siderbar

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

  • I'd be willing to fix this bug myself.

I'm sorry but we need a repro for this kind of bug report because steps are often not enough and ambiguous

https://stackblitz.com/edit/github-pmrjwx?file=docs%2Findex.mdx,sidebars.ts

CleanShot 2024-04-11 at 12 08 26@2x

Most likely this is a duplicate of this: #9923 (comment)