Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Category with no items is being removed from the sidebar #7348

Closed
6 of 7 tasks
kolos450 opened this issue May 5, 2022 · 7 comments · Fixed by #7385
Closed
6 of 7 tasks

Category with no items is being removed from the sidebar #7348

kolos450 opened this issue May 5, 2022 · 7 comments · Fixed by #7385
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@kolos450
Copy link

kolos450 commented May 5, 2022

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.

// If the current category doesn't have subitems, we render a normal link

This behavior has been broken in 2.0.0-beta19 by the new draft documents feature.
The code below removes such items now.

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.
@kolos450 kolos450 added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels May 5, 2022
@slorber
Copy link
Collaborator

slorber commented May 5, 2022

it is expected that draft items are removed from prod build, and that empty categories are removed too

I don't understand the problem. The concept of "draft doc" is new.

Please create a repro or at least give markdown file contents

@kolos450
Copy link
Author

kolos450 commented 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:


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.

@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label May 6, 2022
@Josh-Cena
Copy link
Collaborator

Thanks for the report @kolos450 you seems to have nailed the cause. Before I investigate this, PRs welcome!

@Josh-Cena
Copy link
Collaborator

Fixed in #7385. Please try the canary version.

jslvtr added a commit to tecladocode/rest-apis-flask-python that referenced this issue May 11, 2022
…showing

Bug facebook/docusaurus#7348 made categories disappear when all they had was an index.md file (or README.md) and sub-folders. Updating to canary brings them back.
@andrewnicols
Copy link
Contributor

Thanks - confirmed working with Canary.

@webbertakken
Copy link
Contributor

I can also confirm. Works like a charm on canary 0.0.0-5035.

jslvtr added a commit to tecladocode/rest-apis-flask-python that referenced this issue May 27, 2022
…showing

Bug facebook/docusaurus#7348 made categories disappear when all they had was an index.md file (or README.md) and sub-folders. Updating to canary brings them back.
@slorber
Copy link
Collaborator

slorber commented May 27, 2022

now released in beta.21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants