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

Autogenerated category with directory prevents build #7358

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

Autogenerated category with directory prevents build #7358

andrewnicols opened this issue May 6, 2022 · 2 comments · Fixed by #7385
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: duplicate This issue or pull request already exists in another issue or pull request

Comments

@andrewnicols
Copy link
Contributor

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

Given the following directory structure:

.
└── docs
    └── tutorials
        └── tutorails-basics
            └── index.md

And the following sidebars.js configuration:

const sidebars = {
  docs: [
    'intro',
    {
      label: 'Tutorials',
      type: 'category',
      items: [
        {. 
          type: 'autogenerated',
          dirName: 'tutorials',
        },
      ],
    },
  ],
};

Then I should see a nested sidebar

However, I get the following exception:

❯ yarn start
$ docusaurus start
[INFO] Starting the development server...
[ERROR] Sidebars file at "/home/projects/github-1awfyk/sidebars.js" failed to be loaded.
[ERROR] Loading of version failed for version current
[ERROR] Error: Sidebar category Tutorials has neither any subitem nor a link. This makes this item not able to link to anything.
    at postProcessSidebarItem (/home/projects/github-1awfyk/node_modules/@docusaurus/plugin-content-docs/lib/sidebars/postProcessor.js:40:23)
    at eval (/home/projects/github-1awfyk/node_modules/@docusaurus/plugin-content-docs/lib/sidebars/postProcessor.js:63:84)
    at Array.map (<anonymous>)
    at eval (/home/projects/github-1awfyk/node_modules/@docusaurus/plugin-content-docs/lib/sidebars/postProcessor.js:63:70)
    at eval (/home/projects/github-1awfyk/node_modules/lodash/lodash.js:13469:38)
    at eval (/home/projects/github-1awfyk/node_modules/lodash/lodash.js:4967:15)
    at baseForOwn (/home/projects/github-1awfyk/node_modules/lodash/lodash.js:3032:24)
    at Function.mapValues (/home/projects/github-1awfyk/node_modules/lodash/lodash.js:13468:7)
    at postProcessSidebars (/home/projects/github-1awfyk/node_modules/@docusaurus/plugin-content-docs/lib/sidebars/postProcessor.js:63:29)
    at loadSidebars (/home/projects/github-1awfyk/node_modules/@docusaurus/plugin-content-docs/lib/sidebars/index.js:85:56)
    at async doLoadVersion (/home/projects/github-1awfyk/node_modules/@docusaurus/plugin-content-docs/lib/index.js:93:34)
    at async loadVersion (/home/projects/github-1awfyk/node_modules/@docusaurus/plugin-content-docs/lib/index.js:115:28)
    at async Promise.all (index 0)
    at async Object.loadContent (/home/projects/github-1awfyk/node_modules/@docusaurus/plugin-content-docs/lib/index.js:123:33)
    at async eval (/home/projects/github-1awfyk/node_modules/@docusaurus/core/lib/server/plugins/index.js:35:25)
    at async Promise.all (index 0)

However, having a directory which only contains child directories works if the autogenerated directory is at the top:

const sidebars = {
  tutorialSidebar: [{type: 'autogenerated', dirName: '.'}],
};

Reproducible demo

https://stackblitz.com/edit/github-1awfyk?file=sidebars.js

Steps to reproduce

Create a sidebar configuration where the directory described in an autogenerated sidebar only has directories directly inside it.

Expected behavior

Nested auto-generated indexes should work from any level, as they did in beta 18.

Actual behavior

❯ yarn start
$ docusaurus start
[INFO] Starting the development server...
[ERROR] Sidebars file at "/home/projects/github-1awfyk/sidebars.js" failed to be loaded.
[ERROR] Loading of version failed for version current
[ERROR] Error: Sidebar category Tutorials has neither any subitem nor a link. This makes this item not able to link to anything.
    at postProcessSidebarItem (/home/projects/github-1awfyk/node_modules/@docusaurus/plugin-content-docs/lib/sidebars/postProcessor.js:40:23)
    at eval (/home/projects/github-1awfyk/node_modules/@docusaurus/plugin-content-docs/lib/sidebars/postProcessor.js:63:84)
    at Array.map (<anonymous>)
    at eval (/home/projects/github-1awfyk/node_modules/@docusaurus/plugin-content-docs/lib/sidebars/postProcessor.js:63:70)
    at eval (/home/projects/github-1awfyk/node_modules/lodash/lodash.js:13469:38)
    at eval (/home/projects/github-1awfyk/node_modules/lodash/lodash.js:4967:15)
    at baseForOwn (/home/projects/github-1awfyk/node_modules/lodash/lodash.js:3032:24)
    at Function.mapValues (/home/projects/github-1awfyk/node_modules/lodash/lodash.js:13468:7)
    at postProcessSidebars (/home/projects/github-1awfyk/node_modules/@docusaurus/plugin-content-docs/lib/sidebars/postProcessor.js:63:29)
    at loadSidebars (/home/projects/github-1awfyk/node_modules/@docusaurus/plugin-content-docs/lib/sidebars/index.js:85:56)
    at async doLoadVersion (/home/projects/github-1awfyk/node_modules/@docusaurus/plugin-content-docs/lib/index.js:93:34)
    at async loadVersion (/home/projects/github-1awfyk/node_modules/@docusaurus/plugin-content-docs/lib/index.js:115:28)
    at async Promise.all (index 0)
    at async Object.loadContent (/home/projects/github-1awfyk/node_modules/@docusaurus/plugin-content-docs/lib/index.js:123:33)
    at async eval (/home/projects/github-1awfyk/node_modules/@docusaurus/core/lib/server/plugins/index.js:35:25)
    at async Promise.all (index 0)

Your environment

Self-service

  • I'd be willing to fix this bug myself.
@andrewnicols andrewnicols 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 6, 2022
@Josh-Cena
Copy link
Collaborator

Josh-Cena commented May 6, 2022

Duplicate of #7348 (I think)

It's interesting that they are manifested differently, but I think they are ultimately the same issue. I'll fix it this weekend.

@Josh-Cena Josh-Cena marked this as a duplicate of #7348 May 6, 2022
@Josh-Cena Josh-Cena added closed: duplicate This issue or pull request already exists in another issue or pull request and removed status: needs triage This issue has not been triaged by maintainers labels May 6, 2022
@Josh-Cena
Copy link
Collaborator

Fixed in #7385. Please try the canary version.

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 closed: duplicate This issue or pull request already exists in another issue or pull request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants