Skip to content

Labels do not have unique translation keys #10913

@mike-solomon

Description

@mike-solomon

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

In the sidebars.ts file, if you give multiple objects the same label (e.g., "How-to guides"), they will not generate unique translation keys. This means that the description field on those objects will not work as one of the objects will clobber all of the other ones.

As an example, let's say I want my site to look like this:

Topic A
  Getting Started
    ...
  How to guides
    ...
  References
    ...
Topic B
  Getting Started
    ...
  How to guides
    ...
  References
    ...

In my sidebars.ts file, I figured I could do something like this:

type: 'category',
label: 'References',
link: {
  type: 'generated-index',
  title: 'References',
  description: 'Moderne DX reference docs.',
  slug: '/administrator-documentation/moderne-dx/references',
  keywords: ['reference'],
},

and

type: 'category',
label: 'References',
link: {
  type: 'generated-index',
  title: 'References',
  description: 'Moderne Platform reference docs.',
  slug: '/administrator-documentation/moderne-platform/references',
  keywords: ['reference'],
},

However, that will result in one of the categories not having the correct description:

Image

Image

Related information here: #10906 (comment)

Reproducible demo

https://github.com/mike-solomon/docusaurus-testing/tree/main/website

Steps to reproduce

  1. Launch the side.
  2. Navigate to foo/how-to.
  3. Notice that it has the description for the bar/how-to page.

Expected behavior

I would expect the descriptions on the category pages to match what I wrote in the sidebars.ts file.

Actual behavior

One or more of my pages descriptions gets clobbered with the incorrect description.

Your environment

Self-service

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its execution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions