Skip to content

Refactor autogenerated sidebar groups#3618

Open
HiDeoo wants to merge 11 commits intowithastro:mainfrom
HiDeoo:hd/refactor-autogenerated-groups
Open

Refactor autogenerated sidebar groups#3618
HiDeoo wants to merge 11 commits intowithastro:mainfrom
HiDeoo:hd/refactor-autogenerated-groups

Conversation

@HiDeoo
Copy link
Copy Markdown
Member

@HiDeoo HiDeoo commented Dec 9, 2025

Description

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, and autogroup). This PR has gone through multiple variations of such approach, and the current implementation does not introduce new types but rather adds an autogenerated property set to to true for 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-sidebar plugin, 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 collapsed state of autogenerated subgroups.

Remaining tasks

  • Add changeset

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Dec 9, 2025

🦋 Changeset detected

Latest commit: 3e793dd

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 Minor

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

@netlify
Copy link
Copy Markdown

netlify bot commented Dec 9, 2025

Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit 3e793dd
🔍 Latest deploy log https://app.netlify.com/projects/astro-starlight/deploys/69cac48567171d00071b5451
😎 Deploy Preview https://deploy-preview-3618--astro-starlight.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added 📚 docs Documentation website changes 🌟 core Changes to Starlight’s main package labels Dec 9, 2025
@astrobot-houston
Copy link
Copy Markdown
Contributor

astrobot-houston commented Dec 9, 2025

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/frontmatter.md 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.

parseStarlightConfigWithFriendlyErrors({
title: 'Test',
sidebar: [
// @ts-expect-error - Testing invalid config
Copy link
Copy Markdown
Member Author

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.

Copy link
Copy Markdown
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the branch to be aligned with main and noted a few things. Most were notes I can use myself, but one question would be good to get feedback on from you @HiDeoo!

Comment on lines +26 to +29
export interface SidebarAutoLink extends SidebarManualLink {
autogenerated: true;
}

Copy link
Copy Markdown
Member

@delucis delucis Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HiDeoo Did you have an intended use case for this new property? We didn’t distinguish autogenerated groups from other groups previously, so maybe we can just keep treating all links the same once they get generated and omit this property?

I see this mentioned in the PR comment but I don’t understand why plugins would need access to this data.

Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
@delucis delucis added the 🌟 minor Change that triggers a minor release label Mar 25, 2026
@delucis delucis added this to the v0.39 milestone Mar 25, 2026
@delucis delucis marked this pull request as ready for review March 25, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌟 core Changes to Starlight’s main package 📚 docs Documentation website changes 🌟 minor Change that triggers a minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants