Skip to content

Exclude files in autogenerated (e.g. exclude index page of parent category) #6127

@XomegaNet

Description

@XomegaNet

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

When you use a link of type 'doc' in a 'category' sidebar item, which is the default document when you click on that category, it does not hide the linked document inside that category.

  tutorialSidebar: [
    'intro',
    {
      type: 'category',
      label: 'Tutorial Basics',
      link: {type: 'doc', id: 'tutorial-basics/create-a-page'},
      items: [{type: 'autogenerated', dirName: 'tutorial-basics'}],
    },
  ],

If you use autogenerated directory structure though, and set up such a default link inside the _category.json, then it does hide the default document under that category.

{
  "label": "Tutorial - Basics",
  "position": 2,
  "link": { "type": "doc", "id": "create-a-page" }
}

Steps to reproduce

  1. Create a new website using npx create-docusaurus@latest website classic
  2. Update sidebars.js to use the following sidebar
   tutorialSidebar: [
    'intro',
    {
      type: 'category',
      label: 'Tutorial Basics',
      link: {type: 'doc', id: 'tutorial-basics/create-a-page'},
      items: [{type: 'autogenerated', dirName: 'tutorial-basics'}],
    },
  ],
  1. Launch the website using yarn start.
  2. Navigate to Tutorial nav menu.

Expected behavior

The Create a Page item should be hidden under the Tutorial Basic category.

Actual behavior

The Create a Page item is visible under the Tutorial Basic category.

Your environment

  • Public source code:
  • Public site URL: https://xomega.net/docs
  • Docusaurus version used: 2.0.0-beta.13
  • Environment name and version (e.g. Chrome 89, Node.js 16.4):
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS):

Reproducible demo

No response

Self-service

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    closed: duplicateThis issue or pull request already exists in another issue or pull requestfeatureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions