Category with no items is being removed from the sidebar
See original GitHub issueHave you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I’m using the latest version of Docusaurus.
- I have tried the
npm run clear
oryarn 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
Sidebar items postprocessor nicely converted empty categories to normal links. https://github.com/facebook/docusaurus/blob/9207cafec720d65aca58f104943562046d8f861b/packages/docusaurus-plugin-content-docs/src/sidebars/postProcessor.ts#L53
This behavior has been broken in 2.0.0-beta19 by the new draft documents feature. The code below removes such items now. https://github.com/facebook/docusaurus/blob/9207cafec720d65aca58f104943562046d8f861b/packages/docusaurus-plugin-content-docs/src/sidebars/processor.ts#L93
Reproducible demo
No response
Steps to reproduce
-
Create a new Docusaurus website,
npx create-docusaurus@latest website classic
. -
Use the following
sidebars.js
:const sidebars = { tutorialSidebar: [ { type: 'doc', label: 'Intro', id: 'intro' }, { type: 'category', label: 'Congrats', items: [], link: { type: 'doc', id: 'tutorial-basics/congratulations' } } ] }; module.exports = sidebars;
Expected behavior
Two items in the sidebar.
Actual behavior
A single item in the sidebar.
Your environment
- Docusaurus version used: 2.0.0-beta19
Self-service
- I’d be willing to fix this bug myself.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Service Catalog Categories not displaying - ServiceNow
Hi Everyone, I am attempting to update our Service Catalog (previously deactivated), however I am not seeing any categories listed in the ...
Read more >How to restore items in the Finder sidebar - Macworld
Adele Higgins asks: I somehow removed the Documents category from the Finder's menu list on the far left of the screen on my...
Read more >How to configure category page with / without sidebar
If you do not want to show the sidebar, select Products -> Categories -> (select category) -> Display settings -> Anchor and select...
Read more >Woocommerce No Sidebar on product-category pages
you can see that the wordpress categories pages has no sidebars. This doesn't appear to be a theme options setting that I can...
Read more >How to Remove the Sidebar in WordPress - WPBeginner
Many of the best WordPress themes come with built-in settings to remove sidebars. Depending on your theme, you can remove them site-wide, or ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No, empty categories were not removed but converted to links if their
link
property wasn’t empty as of 2.0.0-beta18.But in 2.0.0-beta19 this behavior was changed. I believe it’s a typo, but such empty categories are considered drafts and removed now. Please examine the following lines: https://github.com/facebook/docusaurus/blob/9207cafec720d65aca58f104943562046d8f861b/packages/docusaurus-plugin-content-docs/src/sidebars/processor.ts#L93
items
property is empty andevery
returnstrue
.Markdown file contents play no role, the only change from the initial skeleton is sidebars.js file.
now released in beta.21