diff options
author | Felix Schneider | 2025-04-05 17:13:25 +0200 |
---|---|---|
committer | GitHub | 2025-04-05 17:13:25 +0200 |
commit | 5bdf139191a20f19458b027617877c1063b46724 (patch) | |
tree | 50a6ccdb53d8fae297b38497059a24cf492a7952 | |
parent | b8e487a50b27a2504abd472bb8276ba03063efb6 (diff) | |
download | IT.starlight-5bdf139191a20f19458b027617877c1063b46724.tar.gz IT.starlight-5bdf139191a20f19458b027617877c1063b46724.tar.bz2 IT.starlight-5bdf139191a20f19458b027617877c1063b46724.zip |
fix(core): `isFallback` type is `true` instead of `boolean` (#3030)
-rw-r--r-- | .changeset/brown-bottles-stare.md | 5 | ||||
-rw-r--r-- | packages/starlight/__tests__/basics/starlight-page-route-data.test.ts | 2 | ||||
-rw-r--r-- | packages/starlight/utils/routing/types.ts | 4 | ||||
-rw-r--r-- | packages/starlight/utils/starlight-page.ts | 5 |
4 files changed, 10 insertions, 6 deletions
diff --git a/.changeset/brown-bottles-stare.md b/.changeset/brown-bottles-stare.md new file mode 100644 index 00000000..8ad54d1e --- /dev/null +++ b/.changeset/brown-bottles-stare.md @@ -0,0 +1,5 @@ +--- +'@astrojs/starlight': patch +--- + +Updates the type of the `isFallback` field in route data from `true` to `boolean`, keeping it optional but allowing `false` as a possible value. diff --git a/packages/starlight/__tests__/basics/starlight-page-route-data.test.ts b/packages/starlight/__tests__/basics/starlight-page-route-data.test.ts index 972dbfe4..416eb735 100644 --- a/packages/starlight/__tests__/basics/starlight-page-route-data.test.ts +++ b/packages/starlight/__tests__/basics/starlight-page-route-data.test.ts @@ -64,11 +64,13 @@ test('adds custom data to route shape', async () => { hasSidebar: false, dir: 'rtl', lang: 'ks', + isFallback: true, }; const data = await generateStarlightPageRouteData({ props, url: starlightPageUrl }); expect(data.hasSidebar).toBe(props.hasSidebar); expect(data.entryMeta.dir).toBe(props.dir); expect(data.entryMeta.lang).toBe(props.lang); + expect(data.isFallback).toBe(props.isFallback); }); test('adds custom frontmatter data to route shape', async () => { diff --git a/packages/starlight/utils/routing/types.ts b/packages/starlight/utils/routing/types.ts index 1f352dd3..13e69188 100644 --- a/packages/starlight/utils/routing/types.ts +++ b/packages/starlight/utils/routing/types.ts @@ -67,8 +67,8 @@ export interface Route extends LocaleData { slug: string; /** The slug or unique ID if using the `legacy.collections` flag. */ id: string; - /** True if this page is untranslated in the current language and using fallback content from the default locale. */ - isFallback?: true; + /** Whether this page is untranslated in the current language and using fallback content from the default locale. */ + isFallback?: boolean; [key: string]: unknown; } diff --git a/packages/starlight/utils/starlight-page.ts b/packages/starlight/utils/starlight-page.ts index 97a3d7d9..48f9ad33 100644 --- a/packages/starlight/utils/starlight-page.ts +++ b/packages/starlight/utils/starlight-page.ts @@ -105,7 +105,7 @@ export async function generateStarlightPageRouteData({ props: StarlightPageProps; url: URL; }): Promise<StarlightRouteData> { - const { isFallback, frontmatter, ...routeProps } = props; + const { frontmatter, ...routeProps } = props; const slug = urlToSlug(url); const pageFrontmatter = await getStarlightPageFrontmatter(frontmatter); const id = project.legacyCollections ? `${stripLeadingAndTrailingSlashes(slug)}.md` : slug; @@ -163,9 +163,6 @@ export async function generateStarlightPageRouteData({ slug, }), }; - if (isFallback) { - routeData.isFallback = true; - } return routeData; } |