diff --git a/.changeset/cool-moons-thank.md b/.changeset/cool-moons-thank.md new file mode 100644 index 00000000000..ec20b8780d5 --- /dev/null +++ b/.changeset/cool-moons-thank.md @@ -0,0 +1,5 @@ +--- +'@astrojs/starlight': patch +--- + +Prevent Starlight crashing when the content folder doesn't exist, or is empty diff --git a/packages/starlight/utils/routing.ts b/packages/starlight/utils/routing.ts index 56bd7c84ab0..6af940c801b 100644 --- a/packages/starlight/utils/routing.ts +++ b/packages/starlight/utils/routing.ts @@ -35,7 +35,7 @@ interface Path extends GetStaticPathsItem { const normalizeIndexSlug = (slug: string) => (slug === 'index' ? '' : slug); /** All entries in the docs content collection. */ -const docs: StarlightDocsEntry[] = (await getCollection('docs')).map(({ slug, ...entry }) => ({ + const docs: StarlightDocsEntry[] = (await getCollection('docs') ?? []).map(({ slug, ...entry }) => ({ ...entry, slug: normalizeIndexSlug(slug), }));