Demo
The “Demo” group visible in the sidebar is an autogenerated group defined using the following configuration:
starlight({ sidebar: [ { label: 'Demo', autogenerate: { directory: 'demo' }, }, ],})The src/content/docs/demo/ directory contains the following files and directories:
Directorydocs
- …
Directorydemo
Directoryapi
- order.md
- product.md
- user.md
Directorychangelog
- v1-0-0.md
- v2-0-0.md
- v3-0-0.md
- overview.mdx
- …
By default, the following sidebar group will be generated by Starlight:
The Starlight Auto Sidebar plugin is used to customize various aspects of autogenerated sidebar groups:
- Rename the
changelogdirectory sidebar label toRelease Notes - Change the sorting order of the
changelogdirectory to be reversed - Rename the
apidirectory sidebar label toAPI - Add an
Experimentalcaution badge to theapidirectory sidebar label - Collapse the
apidirectory in the sidebar
Steps
Here are all the steps to customize the autogenerated sidebar groups to match the rendered sidebar:
-
Rename the
changelogdirectoryTo rename the
changelogdirectory sidebar label toRelease Notes, a metadata file located in thesrc/content/docs/reference/changelog/directory is used.The
labelproperty is used to set the new label:src/content/docs/reference/changelog/_meta.yml # Set the directory sidebar label to `Release Notes`.label: Release Notes -
Change the sorting order of the
changelogdirectoryBy default, content in an autogenerated sidebar groups is sorted by a user-specified order defined in a frontmatter field or alphabetically by slug. For a directory containing release notes, it might be useful to reverse the sorting order so that the latest release notes are displayed first.
To change the sorting order of the
changelogdirectory, a metadata file located in thesrc/content/docs/reference/changelog/directory is used. Thesortproperty is used to control the sorting order of the content in the directory:src/content/docs/reference/changelog/_meta.yml # Reverse the sorting order of the directory content.sort: reverse-slug -
Rename the
apidirectoryTo rename the
apidirectory sidebar label toAPI, a metadata file located in thesrc/content/docs/reference/api/directory is used.The
labelproperty is used to set the new label:src/content/docs/reference/api/_meta.yml # Set the directory sidebar label to `API`.label: API -
Add an
Experimentalcaution badge to theapidirectoryTo add an
Experimentalcaution badge to theapidirectory sidebar label, a metadata file located in thesrc/content/docs/reference/api/directory is used.The
badgeproperty is used to add a badge to the directory sidebar label:src/content/docs/reference/api/_meta.yml # Add a caution badge to the directory sidebar label.badge:text: Experimentalvariant: caution -
Collapse the
apidirectoryTo collapse the
apidirectory in the sidebar, a metadata file located in thesrc/content/docs/reference/api/directory is used.The
collapsedproperty is used to make the directory collapsed in the sidebar:src/content/docs/reference/api/_meta.yml # Collapse the directory in the sidebar.collapsed: true
Check out the metadata reference to learn more about all the available customization options.