diff options
author | Reuben Tier | 2023-09-27 12:18:55 +0100 |
---|---|---|
committer | GitHub | 2023-09-27 13:18:55 +0200 |
commit | 006d60695761ec10e5c4e715ed2212cd1fbedda0 (patch) | |
tree | 80e632aa71360a526f4b31d45acd24410cf4d4da | |
parent | e7163ea050fca193321ffe1049485801a7c92667 (diff) | |
download | IT.starlight-006d60695761ec10e5c4e715ed2212cd1fbedda0.tar.gz IT.starlight-006d60695761ec10e5c4e715ed2212cd1fbedda0.tar.bz2 IT.starlight-006d60695761ec10e5c4e715ed2212cd1fbedda0.zip |
Prevent crashing with no content folder (#745)
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
-rw-r--r-- | .changeset/cool-moons-thank.md | 5 | ||||
-rw-r--r-- | packages/starlight/utils/routing.ts | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/.changeset/cool-moons-thank.md b/.changeset/cool-moons-thank.md new file mode 100644 index 00000000..ec20b878 --- /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 56bd7c84..6af940c8 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), })); |