question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Category with no items is being removed from the sidebar

See original GitHub issue

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

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

  1. Create a new Docusaurus website, npx create-docusaurus@latest website classic.

  2. 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:closed
  • Created a year ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kolos450commented, May 5, 2022

empty categories are removed too

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 and every returns true.

at least give markdown file contents

Markdown file contents play no role, the only change from the initial skeleton is sidebars.js file.

0reactions
slorbercommented, May 27, 2022

now released in beta.21

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found