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

Feature: Organizing Files #393

Open
yousinix opened this issue Oct 8, 2024 · 0 comments
Open

Feature: Organizing Files #393

yousinix opened this issue Oct 8, 2024 · 0 comments

Comments

@yousinix
Copy link

yousinix commented Oct 8, 2024

Currently there's no way to put files in a directory for organization purposes without it affecting the href of that page.

For example, if you want to put all your root tab's files under one directory, to separate it from other tabs, that won't be possible.

It will be great to have something like Route Groups from NextJS, which allows more flexibility.

Approaches

Given the following directory structure, the docs.json can have different possible configuration to enable such a feature.

docs/
  (root)/
    index.mdx
    guides/
      quick-start.mdx

Approach I: path Property

Then a path property would be needed in docs.json if the href is different than the location of the file. This allows full-flexibility (i.e. the href can be totally cha, but on the other hand it's also a bit verbose.

{
  "sidebar": [
    {
      "tab": "root",
      "pages": [
        {
          "title": "Introduction",
          "path": "/(root)/index.mdx", // or "/(root)/"
          "href": "/"
        },
        {
          "title": "Quick Start",
          "path": "/(root)/guides/quick-start.mdx",
          "href": "/guides/foo" // can also be used to fully customize URLs
        }
      ]
    }
  ]
}
Pros Cons
More flexible, as href can be changed to something other than the file name More verbose

Approach II: Resolving Paths

Instead of forcing the user to manually type the path and href, they can just use the existing syntax, but the href path resolution will change.

This means that the href of /guides/quick-start can be located in any of the following files:

  1. docs/guides/quick-start.mdx
  2. docs/guides/quick-start/index.mdx
  3. docs/(**)/guides/quick-start.mdx
  4. docs/(**)/(**)/guides/quick-start.mdx
  5. docs/(**)/(**)/guides/(**)/quick-start.mdx
Pros Cons
Backwards compatible Possible resolution conflicts, in case two groups have the same path
Less verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant