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

Cannot link directly to doc in sidebar #1993

Closed
flaurida opened this issue Nov 14, 2019 · 6 comments · Fixed by #1994
Closed

Cannot link directly to doc in sidebar #1993

flaurida opened this issue Nov 14, 2019 · 6 comments · Fixed by #1994
Labels
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

Comments

@flaurida
Copy link

flaurida commented Nov 14, 2019

🐛Cannot link directly to doc in sidebar

I am trying to link to a doc directly in the sidebar per the v2 documentation.

To Reproduce

(Write your steps here:)

  1. Add doc link in sidebars.js code
module.exports = {
  docs: [
    {
      type: "category",
      label: "Get Started",
      items: ["get_started"]
    },
    { 
     type: "doc",
     id: "api"
    }
  ]
};
  1. Run npm run start

Expected behavior

No compile errors, we see the link directly to the doc in the sidebar.

Actual Behavior

It will not compile, see this error in console:

Error: Unknown sidebar item keys: id. Item: {"type":"doc","id":"api"}

@flaurida flaurida 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 Nov 14, 2019
@endiliey
Copy link
Contributor

You can't do that.

First level of a sidebar name docs must be category

// sidebars.js
module.exports = {
  docs: [
    {
      type: 'category',
      label: 'Getting Started',
      items: ['greeting'],
    },
    {
      type: 'category',
      label: 'Docusaurus',
      items: ['doc1'],
    },
  ],
};

We should update the docs or at least do better in the error handling i guess

@flaurida
Copy link
Author

Oh OK, thanks for clarifying!

@endiliey
Copy link
Contributor

Thank you. We'll warn it to user better in #1994

@flaurida
Copy link
Author

Appreciate the quick follow up 🎉

@binarylogic
Copy link
Contributor

I actually disagree with this behavior. Why can't a category be a page? A side effect of this is that parent URLs don't work. Ex: /docs/category/child, the URL /docs/category returns a 404.

Related general URL issues: #1941 and #1973

@endiliey
Copy link
Contributor

See #2032

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 status: needs triage This issue has not been triaged by maintainers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants