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
changelog
directory sidebar label toRelease Notes
- Change the sorting order of the
changelog
directory to be reversed - Rename the
api
directory sidebar label toAPI
- Add an
Experimental
caution badge to theapi
directory sidebar label - Collapse the
api
directory in the sidebar
Steps
Here are all the steps to customize the autogenerated sidebar groups to match the rendered sidebar:
-
Rename the
changelog
directoryTo rename the
changelog
directory sidebar label toRelease Notes
, a metadata file located in thesrc/content/docs/reference/changelog/
directory is used.The
label
property 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
changelog
directoryBy 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
changelog
directory, a metadata file located in thesrc/content/docs/reference/changelog/
directory is used. Thesort
property 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
api
directoryTo rename the
api
directory sidebar label toAPI
, a metadata file located in thesrc/content/docs/reference/api/
directory is used.The
label
property 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
Experimental
caution badge to theapi
directoryTo add an
Experimental
caution badge to theapi
directory sidebar label, a metadata file located in thesrc/content/docs/reference/api/
directory is used.The
badge
property 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
api
directoryTo collapse the
api
directory in the sidebar, a metadata file located in thesrc/content/docs/reference/api/
directory is used.The
collapsed
property 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.