acrobit / docusaurus-plugin-auto-sidebars

A docusaurus plugin that generates the sidebar items automatically by filesystem structure
21 stars 5 forks source link

Is there a way to order files and folders? #3

Open metasaver opened 4 years ago

metasaver commented 4 years ago
  1. At the root level, I would like to move an Introduction page to above the first folder.
  2. My root level folders are all ordered correctly (Works well)
  3. My sub-folders are not ordered in the way I would like them.
  4. I would also like to put another intro.md file as the first entry

Is any of this possible in the current implementation, I have scoured the example and docs but haven't been able to find anything.

Btw, very nice plugin.

This is my sidebars file - it doesn't throw an error. image

This is the result. The arrows are where I am trying to get the files to show up (#1 & 4), the order of level 2 is alphabetical, not as in the sidebars.yml image

Thanks

ghominejad commented 4 years ago

Hi @metasaver, The sidebars.yaml file is used for naming, ordering and also hiding the folders but not files. you don't need to define them inside sidebar.yaml. Maybe was better we would name it folders.yaml.

If you want to order files you can add a number to the beginning of the files (in file system).

1.fileX.md
2.fileY.md
3.fileX.md

You can also use negative numbers to display them in reverse order :

-1.fileX.md
-2.fileY.md
-3.fileX.md

You need to put a dot after the number

Hope this helps.

metasaver commented 4 years ago

-1 seems to work thanks. Btw they werent files but sub folders in my yaml. I was just trying order like this:

file subfolder subfolder subfolder file

ghominejad commented 4 years ago

The order of files and folders are sync together. You can also start from 1

filesystem:

1. file
5. file

yaml file:

subfolder : 2
subfolder : 3
subfolder : 4
booshnelli commented 4 years ago

@metasaver hey just thought i'd mention i've found lettering the files (instead of numbering) in the filesystem to work a bit better. like this:

a.bananas.md
b.apples.md

this will successfully put bananas.md on top with apples.md below it, and put them both above all the subfolders.

otherwise to get the same effect with numbers i have to do:

-2.bananas.md
-1.apples.md

anyway just thought i'd share my findings. really liking this plugin 😊

ghominejad commented 4 years ago

Hi @Boosh511, thanks for your feedback!

I'm glad you found this useful.