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

docsVersionDropdown showing in nav bar even for non-versioned site #9586

Closed
4 of 7 tasks
aliahameed opened this issue Nov 27, 2023 · 1 comment
Closed
4 of 7 tasks
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

@aliahameed
Copy link

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

Hi,

I have spent a few days scouring the internet for information on this issue; found a few people with similar issues but in my case it really seems as though Docusaurus is not working as expected.

Basically, I have my regular documentation site in the docs folder, and this is versioned. I included the docsVersionDropdown item in the nav bar, it's displayed as expected. Now I'm also using the plugin-content-docs to display a second documentation instance (this is because in some cases, I need to be able to display a subset of my documentation site). The markdown pages for this second documentation instance are in a different folder (src/embedded-pages) (this isn't ideal because they're just duplicates of the pages already in the docs folder, but I couldn't find any other way to do it, after spending over a week searching).

The problem: the docsVersionDropdown item is showing for this second documentation site also, whereas this second documentation site is not versioned. Docusaurus even knows that it's not versioned, because when I try to add "disableVersioning: true" to the plugin-content-docs, it throws an error, saying: "using "disableVersioning: true" option on a non-versioned site does not make sense."

I tried specifying in the navbar section that the docsVersionDropdown should only be displayed for the default instance, like so:

navbar: {
      items: [
       {
         type: 'docsVersionDropdown',
         position: 'left',
         dropdownItemsAfter: [{to: '/versions', label: 'All versions'}],
         dropdownActiveClassDisabled: true,
   	  docsPluginId: 'default',
       },
     ],

But this didn't work. The docsVersionDropdown is displayed even for the site which isn't versioned. If one clicks on any of the versions in the list, one is (of course) redirected to the other site, the one which is versioned. This surely seems like a bug?

Many thanks in advance for any advice/suggestions!

Reproducible demo

No response

Steps to reproduce

  1. Set up a "docs" site.
  2. Version it.
  3. Add docsVersionDropdown item to the nav bar to display the list of versions.
  4. Use plugin-content-docs to set up a second documentation site.
  5. You'll see that the docsVersionDropdown item is showing on this second site too even though it isn't versioned.

Expected behavior

I would have expected the docsVersionDropdown not to show up for an unversioned site. If it's going to show up anyway, it should be possible to use the "disableVersioning: true" option to hide it.

Actual behavior

The docsVersionDropdown is showing up everywhere.

Your environment

  • Docusaurus version used: 2.4.3
  • Node version: v20.9.0

Self-service

  • I'd be willing to fix this bug myself.
@aliahameed aliahameed 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 27, 2023
@slorber
Copy link
Collaborator

slorber commented Nov 30, 2023

Please spend time to create a runnable repro using Docusaurus.new, using latest version of Docusaurus.

Until a repro is provided demonstrating the issue, let's close.

I believe you simply misunderstand how the navbar works: the navbar items are static and the same navbar items will be displayed for both docs plugin instances.

There's a feature request for "dynamic navbar items": #4389

Until we implement this you can use custom CSS to hide unwanted navbar items

@slorber slorber closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2023
@slorber slorber 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 Nov 30, 2023
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

No branches or pull requests

2 participants