Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent crashing with no content folder #745

Merged
merged 8 commits into from
Sep 27, 2023
Merged
5 changes: 5 additions & 0 deletions .changeset/cool-moons-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/starlight': patch
---

Prevent Starlight crashing when the content folder doesn't exist, or is empty
2 changes: 1 addition & 1 deletion packages/starlight/utils/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => ({
TheOtterlord marked this conversation as resolved.
Show resolved Hide resolved
...entry,
slug: normalizeIndexSlug(slug),
}));
Expand Down