-
-
Notifications
You must be signed in to change notification settings - Fork 892
Refactor autogenerated sidebar groups #3618
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
base: main
Are you sure you want to change the base?
Conversation
|
✅ Deploy Preview for astro-starlight ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
| parseStarlightConfigWithFriendlyErrors({ | ||
| title: 'Test', | ||
| sidebar: [ | ||
| // @ts-expect-error - Testing invalid config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to investigate why this error was hoisted (I can guess why, but need to know the specific reason) and see if we can move it back down at the group item level without losing some other type behaviors we expect.

Description
This PR adds a new feature which has been discussed and approved here.
Closes Groupless autogenarated sidebar links #3336
This PR removes the notion of "autogenerated sidebar groups" in favor of simply using "autogenerated sidebar links" which can be used in regular sidebar groups. As discussed in #3336, this simplifies the mental model around groups and also allows for use cases that were not possible before, such as having a sidebar entirely made of autogenerated links for a specific directory without having it nested inside a group.
For users, the gist of the change is:
{ label: 'My group', - autogenerate: { directory: 'some-dir' }, + items: [{ autogenerate: { directory: 'some-dir' } }], }Such refactor removes the 1:1 mapping that was previously available between an autogenerated sidebar group in the Starlight configuration and such autogenerated group in the Starlight route data. To address such change, the Starlight route data has been updated and many solutions are possible to address this, e.g. having multiple types (
link,autolink,group, andautogroup). This PR has gone through multiple variations of such approach, and the current implementation does not introduce new types but rather adds anautogeneratedproperty set to totruefor links and subgroups that were autogenerated. Of course, other approaches are possible and feedback is welcome.To make sure such change does not impact plugins with previous features that would no longer be possible due to the changes, I rewrote locally the
starlight-auto-sidebarplugin, which was heavily relying on that 1:1 mapping and to my knowledge, may be one of the "largest" plugins tweaking sidebar route data for autogenerated groups with a large enough set of tests. I managed to rewrite it successfully while using the Starlight version from this PR and achieved the same results as before.Note: I also addded a few tests for some behaviors that were not covered before and were impacted by this change, e.g. the
collapsedstate of autogenerated subgroups.Remaining tasks