Feat: Autogenerate sidebar labels
Description
- Resolves https://github.com/withastro/starlight/discussions/1630
- Now using a sidebar entry with the key
slugto specify the file will dynamically pull in that file's title
TODOs
- [ ] Do the test updates look alright? I added on to the current tests instead of breaking out into a separate one, but can do that if wanted
- [ ] Changeset
- [ ] Docs updates
The latest updates on your projects. Learn more about Vercel for Git βοΈ
| Name | Status | Preview | Updated (UTC) |
|---|---|---|---|
| starlight | β Ready (Inspect) | Visit Preview | Jul 5, 2024 10:55am |
π¦ Changeset detected
Latest commit: 07c06963255ff9c678445976c8acb1c8d645e681
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| @astrojs/starlight | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Lunaria Status Overview
π This pull request will trigger status changes.
Learn more
By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.
You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.
Tracked Files
| Locale | File | Note |
|---|---|---|
| en | guides/sidebar.mdx | Source changed, localizations will be marked as outdated. |
| en | reference/configuration.mdx | Source changed, localizations will be marked as outdated. |
Warnings reference
| Icon | Description |
|---|---|
| ποΈ | The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied. |
Wow! Very nice feature, it will greatly improve the DX!
I also faced this and it feels uncomfortable especially when the sidebar contains autogenerated groups and some manually added items. In this case, the autogenerated pages define their sidebar title in the Front Matter section. At the same time, the manual items should define it in the sidebar configuration.
This is also bad for i18n, because the labels for manually added items should be localized separately using the translations configuration.
Waiting for this to ship! π
Thanks for diving in, @delucis , and feel free to run wild with any of my PRs anytime π
RE: usage in the sidebar guide, I think it's covered pretty well with what you've written. My only though overall for documentation is that it may be helpful to specify this is for files in src/content as "internal" could also be considered for thinks like assets, public files, and non-content collection pages.
My only though overall for documentation is that it may be helpful to specify this is for files in
src/contentas "internal" could also be considered for thinks like assets, public files, and non-content collection pages.
Yes, I also considered that. Thatβs why I used βinternal docs pagesβ, but agree that being more explicit could make sense! Let me have a quick try.
LGTM!
I was just looking for this functionality this morning, perfect timing, and great work! Thank you π