Open cbontems opened 10 months ago
I just started looking at a potential solution, but found this comment:
/**
* Get the sort weight for a given route or directory. Lower numbers rank higher.
* Directories have the weight of the lowest weighted route they contain.
*/
function getOrder(routeOrDir: Route | Dir): number {
for the getOrder
function in utils/navigation.ts
so it looks like it is the expected behaviour for now.
This still look like a problem for me, as I don't want to check potential impact on other folders when I define order between pages inside a given folder.
Here is my use case to illustrate:
When work in a directory, i start by odering my pages by increments of 10.
This way, when I need to insert a page later, I can do so without renumbering all pages.
Now, the problem is when I want to insert a page first in one folder. I will give it order 5, and by doing so, Starlight will not only insert my page first, but will also place this folder on top of my sidebar, which is not what I want.
In addition, nested directories cannot have custom labels.
eg a dir named my-folder
cannot be shown as My Folder
unless you manually add the links.
My suggestion would be to have something simillar on how docusaurus do.
_config.yaml
file (docusaurus has it as _category_.yml
) which you can just add front-matter data, like title,order etcThose should allow you to manually fix the above.
Another dirty solution to this, is to use 1000
range for the first dir, 2000
for the second.
So first dir will be 1010
, 1020
, etc
second dir will be 2010
, 2020
, etc
EDIT: I just saw: https://github.com/withastro/starlight/issues/370 https://github.com/withastro/starlight/pull/1151
I am also highlight interested in both issues:
Is there already a solution for that? Because right now you either have lowercase group labels with inconsistent sorting or a practically fully manual sidebar.
Nuxt Content has a very nice way of supporting custom ordering, by allowing numeric prefixes in the filename, which it then ignores when generating the slug/ID.
What version of
starlight
are you using?0.14.0
What version of
astro
are you using?3.6.4
What package manager are you using?
pnpm
What operating system are you using?
Mac
What browser are you using?
Chrome
Describe the Bug
As discussed on Discord,
If I give my folder-1/page-1.md an order property of 10, and my folder-2/page-1.md an order property of 5, I end-up with my folder-2 being ranked above folder-1 in my sidebar.
Said differently, autogenerated folders are sorted according to the order of the first page in the directory.
In the stackblitz example linked below, in the fruits directory, the banana subdirectory comes before the apples subdirectory because it has a page with order 1, when apples has a page with order 5.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-dssfwv?file=src%2Fcontent%2Fdocs%2Ffruits%2Fbananas%2Flatundan.md
Participation