#2168 e044fee
Thanks @HiDeoo! - ⚠️ BREAKING CHANGE: Updates the <StarlightPage />
component sidebar
prop to accept an array of SidebarItem
s like the main Starlight sidebar
configuration in astro.config.mjs
.
This change simplifies the definition of sidebar items in the <StarlightPage />
component, allows for shared sidebar configuration between the global sidebar
option and <StarlightPage />
component, and also enables the usage of autogenerated sidebar groups with the <StarlightPage />
component.
If you are using the <StarlightPage />
component with a custom sidebar
configuration, you will need to update the sidebar
prop to an array of SidebarItem
objects.
For example, the following custom page with a custom sidebar
configuration defines a “Resources” group with a “New” badge, a link to the “Showcase” page which is part of the docs
content collection, and a link to the Starlight website:
---
// src/pages/custom-page/example.astro
---
<StarlightPage
frontmatter={{ title: 'My custom page' }}
sidebar={[
{
type: 'group',
label: 'Resources',
badge: { text: 'New' },
items: [
{ type: 'link', label: 'Showcase', href: '/showcase/' },
{
type: 'link',
label: 'Starlight',
href: 'https://starlight.astro.build/',
},
],
},
]}
>
<p>This is a custom page with a custom component.</p>
</StarlightPage>
This configuration will now need to be updated to the following:
---
// src/pages/custom-page/example.astro
---
<StarlightPage
frontmatter={{ title: 'My custom page' }}
sidebar={[
{
label: 'Resources',
badge: { text: 'New' },
items: [
'showcase',
{ label: 'Starlight', link: 'https://starlight.astro.build/' },
],
},
]}
>
<p>This is a custom page with a custom component.</p>
</StarlightPage>
See the “Sidebar Navigation” guide to learn more about the available options for customizing the sidebar.