Skip to content

[2.0.0-alpha.73] Numeric value in subdirectory of DOCS yields issues with sideba #4653

Closed

Description

@TomPeirs

🐛 Bug Report

Numeric value in subdirectory of DOCS yields issues with sidebar

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

To Reproduce

If possible, use https://new.docusaurus.io to create a CodeSandbox reproducible demo of the bug.

(Write your steps here:)

  1. Create a subdirectory for your documentation which consists of numeric values as seen below
    image

  2. Change the sidebar and reference the doc. as seen in image below.

module.exports = {
  // By default, Docusaurus generates a sidebar from the docs folder structure
  tutorialSidebar: [{ type: "autogenerated", dirName: "." }],
  testSidebar: [
    {
      collapsed: false,
      items: ["modules/COIS/en/7.0.0/TEST"],
      label: "COIS",
      type: "category"
    }
  ]
};
  1. Run the application.

Expected behavior

I would expect that I can simply reference the markdown file which is nested in a folder with a numeric value.

Actual Behavior

Error: Bad sidebars file.
These sidebar document ids do not exist:
- modules/COIS/en/7.0.0/TEST
Available document ids=
...
- modules/COIS/de/0.0/TEST

As you can see the available ID is actually wrong. it should be modules/COIS/de/7.0.0/TEST but the 7 in the numeric value is gone.

Your Environment

  • Docusaurus version used: 2.0.0-alpha.73"
  • Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0):

Reproducible Demo

https://codesandbox.io/s/inspiring-moore-hvdzp?file=/docs/modules/cois/en/7.0.0/TEST.MD:112-132

Activity

  1. added
    bug
    status: needs triage
    on Apr 20, 2021
  2. slorber commented on Apr 21, 2021

    @slorber
    Collaborator

    Yes, this is a new "number prefix" feature that we introduced recently: by default it will try to parse patterns such as 001-MyDoc.md

    I'm currently working to make this parsing logic configurable (allowing to disable this too) for your site. There's a frontmatter to disable this per doc already.

    It probably makes sense to ignore patterns with consecutive numbers by default, like 2021-01 and 8.0.0, yet parse 8-MyDoc.md

    It is a best-effort because it's hard to predic doc name patterns that users will use, and I think it's convenient to have this feature enabled by default as it easy adoption of Docusaurus for existing docs on github using number prefixes for doc ordering, as the newly introduced autogenerated sidebar would become ordered in the correct order by default.

    Closing as duplicate of #4640

    Will release a fix very soon

  3. TomPeirs commented on Apr 21, 2021

    @TomPeirs
    Author

    Thank you for clarifying :-)

  4. slorber commented on Apr 21, 2021

    @slorber
    Collaborator

    np :)

    PR is here: #4655

    Will be released before the end of the week but you can try using the @canary dist tag once it's merged.

    If you think of any other file/folder pattern using numbers that should not be stripped, let me know

  5. removed
    status: needs triage
    on Feb 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions