Groupless autogenarated sidebar links #3336
Replies: 5 comments 7 replies
-
|
I was just trying to figure out how to configure Starlight to do something like this and it turns out it's not possible. This feature would definitely be handy for adding additional menu items or groups to the default autogenerated sidebar. As things stand, to the best of my knowledge, as soon as you need to add custom menu items the default autogenerated tree has to be packed into a subfolder/group on the sidebar. |
Beta Was this translation helpful? Give feedback.
-
So this would look something like this? sidebar: [
{
label: 'My group',
items: [
{ autogenerate: { directory: 'some-dir' } },
],
}
],vs the current syntax: sidebar: [
{
label: 'My group',
autogenerate: { directory: 'some-dir' },
}
],You like that approach because it means the Could be worth considering whether it’s a worthwhile breaking change to make pre-v1. |
Beta Was this translation helpful? Give feedback.
-
|
I want this too! |
Beta Was this translation helpful? Give feedback.
-
|
I like the combination of both (the items array and a new type property). So it will look something like this: sidebar: [
{
label: 'My group',
items: [
{
type: 'autogenerate',
directory: 'some-dir'
},
],
}
], |
Beta Was this translation helpful? Give feedback.
-
|
I came here at @HiDeoo's mention, My use case was using the wonderful https://starlight-sidebar-topics.netlify.app/ to display a topic list to pick from ala the Astro official docs, and I didn't want to repeat the group when displaying the items in a topic. I could do it using a manual |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What version of
starlightare you using?0.35.1
What is your idea?
This proposal suggests a new alternative to define autogenerated sidebar links that are not relying on sidebar groups to allow for a more flexible usage of autogenerated links in sidebars.
It builds on the existing autogenerated sidebar groups feature by allowing the omission of the
labelproperty.interface Autogenerated { - label: string; + label?: string; autogenerate: { directory: string; }; }When the
labelproperty is omitted, the autogenerated links will no longer be grouped, resulting in a list of links that are not nested under a group label.labelis specified, a group is created to contain the autogenerated links.labelis omitted, a group is not created.Why is this feature necessary?
Here are some use cases that I've encountered where the current autogenerated sidebar groups are not flexible enough.
Single non-root autogenerated sidebar group
Considering the following file structure:
The desired outcome is to have a sidebar that automatically generates links for each file in the
constellations/directory:When using the current autogenerated sidebar groups feature, you would typically define a sidebar group like this:
This results in the following sidebar structure with an extra group that is not desired:
Proposal config to achieve the desired outcome
Mixed autogenerated and manual sidebar links
Considering the following file structure:
The desired outcome is to have an autogenerated sidebar group for the
constellations/directory with an additional first link which would redirect to the NASA website:When using the current autogenerated sidebar groups feature, it's not possible to also to add
itemslike you would in a regular sidebar group, e.g. the following configuration is invalid:Proposal config to achieve the desired outcome
Do you have examples of this feature in other projects?
Other alternatives considered
autogenerateobject, e.g.grouped: false, orspread: true, to indicate that the links should not be grouped. This approach would be less intuitive as you would still need to define a group label even though it would not be used.{ type: autogenerate, directory: "api" }, which is similar to the slice type in Docusaurus. Considering Starlight already has autogenerated sidebar groups, this could lead to confusion between the two types.Participation
Beta Was this translation helpful? Give feedback.
All reactions