> & {
- sidebar?: StarlightPageSidebarUserConfig;
+ sidebar?: StarlightUserConfig['sidebar'];
// And finally add the Starlight page frontmatter properties in a `frontmatter` property.
frontmatter: StarlightPageFrontmatter;
}
@@ -190,9 +114,11 @@ export async function generateStarlightPageRouteData({
const pageFrontmatter = await getStarlightPageFrontmatter(frontmatter);
const id = `${stripLeadingAndTrailingSlashes(slug)}.md`;
const localeData = slugToLocaleData(slug);
- const sidebar = props.sidebar
- ? normalizeSidebarProp(props.sidebar)
- : getSidebar(url.pathname, localeData.locale);
+ const sidebar = getSidebarFromConfig(
+ props.sidebar ? validateSidebarProp(props.sidebar) : config.sidebar,
+ url.pathname,
+ localeData.locale
+ );
const headings = props.headings ?? [];
const pageDocsEntry: StarlightPageDocsEntry = {
id,
From 746957e94e0be0c577b6f63278f132b41d7da6a2 Mon Sep 17 00:00:00 2001
From: HiDeoo <494699+HiDeoo@users.noreply.github.com>
Date: Fri, 16 Aug 2024 14:20:46 +0200
Subject: [PATCH 2/4] chore: remove test content
---
docs/astro.config.mjs | 5 --
docs/src/pages/test-1.astro | 13 ---
docs/src/pages/test-2.astro | 136 ------------------------------
docs/src/pages/test-[index].astro | 61 --------------
4 files changed, 215 deletions(-)
delete mode 100644 docs/src/pages/test-1.astro
delete mode 100644 docs/src/pages/test-2.astro
delete mode 100644 docs/src/pages/test-[index].astro
diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs
index a4c395fb7ee..883bf325bae 100644
--- a/docs/astro.config.mjs
+++ b/docs/astro.config.mjs
@@ -108,11 +108,6 @@ export default defineConfig({
uk: 'Вплив на довкілля',
},
},
- // TODO(HiDeoo) Remove this link
- {
- label: 'Test 1',
- link: '/test-1/',
- },
],
},
{
diff --git a/docs/src/pages/test-1.astro b/docs/src/pages/test-1.astro
deleted file mode 100644
index bc7931bd771..00000000000
--- a/docs/src/pages/test-1.astro
+++ /dev/null
@@ -1,13 +0,0 @@
----
-import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
-
-// TODO(HiDeoo) Remove this file.
----
-
-
-
- No sidebar
props are used with StarlightPage
in this custom page so the
- global sidebar
config should be used.
-
- Continue to the next test page.
-
diff --git a/docs/src/pages/test-2.astro b/docs/src/pages/test-2.astro
deleted file mode 100644
index f783c58d5a8..00000000000
--- a/docs/src/pages/test-2.astro
+++ /dev/null
@@ -1,136 +0,0 @@
----
-import StarlightPage, {
- type StarlightPageProps,
-} from '@astrojs/starlight/components/StarlightPage.astro';
-
-// TODO(HiDeoo) Remove this file.
-
-// This is a copy of the global sidebar. This could be exported & shared between the config and
-// this page. I just didn't want to export the sidebar from the config file for this test.
-const sidebar: StarlightPageProps['sidebar'] = [
- {
- label: 'Start Here',
- translations: {
- de: 'Beginne hier',
- es: 'Comienza aqui',
- ja: 'ここからはじめる',
- fr: 'Commencez ici',
- it: 'Inizia qui',
- id: 'Mulai dari sini',
- 'zh-CN': '从这里开始',
- 'pt-BR': 'Comece Aqui',
- 'pt-PT': 'Comece Aqui',
- ko: '여기서부터',
- tr: 'Buradan Başlayın',
- ru: 'Первые шаги',
- hi: 'यहाँ से शुरू करे',
- uk: 'Почніть звідси',
- },
- items: [
- 'getting-started',
- 'manual-setup',
- {
- label: 'Environmental Impact',
- slug: 'environmental-impact',
- translations: {
- de: 'Umweltbelastung',
- es: 'Documentación ecológica',
- ja: '環境への負荷',
- fr: 'Impact environnemental',
- it: 'Impatto ambientale',
- id: 'Dampak terhadap lingkungan',
- 'zh-CN': '环境影响',
- 'pt-BR': 'Impacto Ambiental',
- 'pt-PT': 'Impacto Ambiental',
- ko: '환경적 영향',
- tr: 'Çevre Etkisi',
- ru: 'Влияние на окружающую среду',
- hi: 'पर्यावरणीय प्रभाव',
- uk: 'Вплив на довкілля',
- },
- },
- {
- label: 'Test 1',
- link: '/test-1/',
- },
- ],
- },
- {
- label: 'Guides',
- translations: {
- de: 'Anleitungen',
- es: 'Guías',
- ja: 'ガイド',
- fr: 'Guides',
- it: 'Guide',
- id: 'Panduan',
- 'zh-CN': '指南',
- 'pt-BR': 'Guias',
- 'pt-PT': 'Guias',
- ko: '가이드',
- tr: 'Rehber',
- ru: 'Руководства',
- hi: 'गाइड',
- uk: 'Ґайди',
- },
- autogenerate: { directory: 'guides' },
- },
- {
- label: 'Reference',
- translations: {
- de: 'Referenz',
- es: 'Referencias',
- ja: 'リファレンス',
- fr: 'Référence',
- it: 'Riferimenti',
- id: 'Referensi',
- 'zh-CN': '参考',
- 'pt-BR': 'Referência',
- ko: '참조',
- tr: 'Referanslar',
- ru: 'Справочник',
- hi: 'संदर्भ',
- uk: 'Довідник',
- },
- autogenerate: { directory: 'reference' },
- },
- {
- label: 'Resources',
- badge: 'New',
- translations: {
- 'zh-CN': '资源',
- fr: 'Ressources',
- 'pt-BR': 'Recursos',
- 'pt-PT': 'Recursos',
- ja: 'リソース',
- ru: 'Ресурсы',
- },
- autogenerate: { directory: 'resources' },
- },
-];
-
-// Add a new autogenerate group to the sidebar
-sidebar.push({
- label: 'More Resources',
- badge: { text: 'Newer', variant: 'danger' },
- autogenerate: { directory: 'resources' },
-});
-
-// Add another new group
-sidebar.push({
- label: 'Tests',
- items: [
- { label: 'Test 1', link: '/test-1/' },
- { label: 'Test 2', link: '/test-2/' },
- { label: 'Test 3', link: '/test-3/' },
- ],
-});
----
-
-
-
- The global sidebar
config is re-used with StarlightPage
in this custom
- page and new groups/links have been appended to it.
-
- Continue to the next test page.
-
diff --git a/docs/src/pages/test-[index].astro b/docs/src/pages/test-[index].astro
deleted file mode 100644
index 0fcf7288ab6..00000000000
--- a/docs/src/pages/test-[index].astro
+++ /dev/null
@@ -1,61 +0,0 @@
----
-import StarlightPage, {
- type StarlightPageProps,
-} from '@astrojs/starlight/components/StarlightPage.astro';
-
-// TODO(HiDeoo) Remove this file.
-
-export function getStaticPaths() {
- return [{ params: { index: '3' } }, { params: { index: '4' } }, { params: { index: '5' } }];
-}
-
-const index = Number.parseInt(Astro.params.index, 10);
-
-const sidebar: StarlightPageProps['sidebar'] = [
- 'getting-started',
- {
- label: 'Tests',
- items: [
- { label: 'Test 1', link: '/test-1/' },
- { label: 'Test 2', link: '/test-2/' },
- { label: 'Test 3', link: '/test-3/' },
- { label: 'Test 4', link: '/test-4/' },
- { label: 'Test 5', link: '/test-5/' },
- ],
- },
- {
- label: 'Recent posts',
- items: [
- { label: 'Article 6', link: '/blog/article-6/' },
- { label: 'Article 5', link: '/blog/article-5/' },
- { label: 'Article 4', link: '/blog/article-4/' },
- { label: 'Article 3', link: '/blog/article-3/' },
- { label: 'Article 2', link: '/blog/article-2/' },
- ],
- },
- {
- label: 'Tags',
- items: [
- { label: 'Starlight', link: '/blog/tags/starlight/' },
- { label: 'Astro', link: '/blog/tags/astro/' },
- ],
- },
- {
- label: 'Reference',
- autogenerate: { directory: 'reference' },
- },
-];
----
-
-
-
- A custom sidebar
config is used with StarlightPage
in this custom page.
-
- {
- index < 5 && (
-
- Continue to the next test page.
-
- )
- }
-
From 3be4e18de94cc4db588f92d0e377f80e38e45f27 Mon Sep 17 00:00:00 2001
From: HiDeoo <494699+HiDeoo@users.noreply.github.com>
Date: Fri, 16 Aug 2024 14:51:35 +0200
Subject: [PATCH 3/4] chore: add changeset
---
.changeset/chilled-kiwis-count.md | 56 +++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 .changeset/chilled-kiwis-count.md
diff --git a/.changeset/chilled-kiwis-count.md b/.changeset/chilled-kiwis-count.md
new file mode 100644
index 00000000000..3d0c3123b6e
--- /dev/null
+++ b/.changeset/chilled-kiwis-count.md
@@ -0,0 +1,56 @@
+---
+'@astrojs/starlight': minor
+---
+
+⚠️ **BREAKING CHANGE:** Updates the `` component `sidebar` prop to accept an array of [`SidebarItem`](https://starlight.astro.build/reference/configuration/#sidebaritem) like the Starlight global `sidebar` configuration.
+
+This change simplifies the definition of sidebar items in the `` component, allows for shared sidebar configuration between the global `sidebar` option and `` component, and also enables the usage of autogenerated sidebar groups with the `` component.
+If you are using the `` component with a custom `sidebar` configuration, you will need to update the `sidebar` prop to an array of [`SidebarItem`](https://starlight.astro.build/reference/configuration/#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:
+
+```tsx
+---
+// src/pages/custom-page/example.astro
+---
+
+
+ This is a custom page with a custom component.
+
+```
+
+This configuration will now need to be updated to the following:
+
+```tsx
+---
+// src/pages/custom-page/example.astro
+---
+
+
+ This is a custom page with a custom component.
+
+```
+
+See the [“Sidebar Navigation”](https://starlight.astro.build/guides/sidebar/) guide to learn more about the available options for customizing the sidebar.
From 4810cbf84ba67b93c8359e92752e94204fad510a Mon Sep 17 00:00:00 2001
From: Chris Swithinbank
Date: Fri, 16 Aug 2024 17:24:13 +0200
Subject: [PATCH 4/4] Tweak changeset
---
.changeset/chilled-kiwis-count.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.changeset/chilled-kiwis-count.md b/.changeset/chilled-kiwis-count.md
index 3d0c3123b6e..dac9116a00d 100644
--- a/.changeset/chilled-kiwis-count.md
+++ b/.changeset/chilled-kiwis-count.md
@@ -2,14 +2,14 @@
'@astrojs/starlight': minor
---
-⚠️ **BREAKING CHANGE:** Updates the `` component `sidebar` prop to accept an array of [`SidebarItem`](https://starlight.astro.build/reference/configuration/#sidebaritem) like the Starlight global `sidebar` configuration.
+⚠️ **BREAKING CHANGE:** Updates the `` component `sidebar` prop to accept an array of [`SidebarItem`](https://starlight.astro.build/reference/configuration/#sidebaritem)s like the main Starlight `sidebar` configuration in `astro.config.mjs`.
This change simplifies the definition of sidebar items in the `` component, allows for shared sidebar configuration between the global `sidebar` option and `` component, and also enables the usage of autogenerated sidebar groups with the `` component.
If you are using the `` component with a custom `sidebar` configuration, you will need to update the `sidebar` prop to an array of [`SidebarItem`](https://starlight.astro.build/reference/configuration/#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:
-```tsx
+```astro
---
// src/pages/custom-page/example.astro
---
@@ -34,7 +34,7 @@ For example, the following custom page with a custom `sidebar` configuration def
This configuration will now need to be updated to the following:
-```tsx
+```astro
---
// src/pages/custom-page/example.astro
---