diff options
author | Chris Swithinbank | 2023-09-28 00:48:42 +0200 |
---|---|---|
committer | GitHub | 2023-09-28 00:48:42 +0200 |
commit | 2ef303649a0b66a6ec6a216815e05d41bf22b594 (patch) | |
tree | f64bfa73b44f891b4ae480868fd1935f37011c66 | |
parent | 423d575cc8227e4db86a85c70c45c0f3f7a184d2 (diff) | |
download | IT.starlight-2ef303649a0b66a6ec6a216815e05d41bf22b594.tar.gz IT.starlight-2ef303649a0b66a6ec6a216815e05d41bf22b594.tar.bz2 IT.starlight-2ef303649a0b66a6ec6a216815e05d41bf22b594.zip |
Replace copy/pasted `ImageFunction` with imported `SchemaContext` (#775)
* Replace copy/pasted `ImageFunction` with imported `SchemaContext`
* Only import type from astro:content
* Add changeset
* Improve changeset
-rw-r--r-- | .changeset/fair-trains-care.md | 5 | ||||
-rw-r--r-- | packages/starlight/schema.ts | 20 |
2 files changed, 7 insertions, 18 deletions
diff --git a/.changeset/fair-trains-care.md b/.changeset/fair-trains-care.md new file mode 100644 index 00000000..e4485429 --- /dev/null +++ b/.changeset/fair-trains-care.md @@ -0,0 +1,5 @@ +--- +"@astrojs/starlight": patch +--- + +Fix content collection schema compatibility with Astro 3.1 and higher diff --git a/packages/starlight/schema.ts b/packages/starlight/schema.ts index d0775e70..89fc47e2 100644 --- a/packages/starlight/schema.ts +++ b/packages/starlight/schema.ts @@ -1,4 +1,5 @@ import { z } from 'astro/zod'; +import type { SchemaContext } from 'astro:content'; import { HeadConfigSchema } from './schemas/head'; import { PrevNextLinkConfigSchema } from './schemas/prevNextLink'; import { TableOfContentsSchema } from './schemas/tableOfContents'; @@ -9,25 +10,8 @@ export { i18nSchema } from './schemas/i18n'; type IconName = keyof typeof Icons; const iconNames = Object.keys(Icons) as [IconName, ...IconName[]]; -type ImageFunction = () => z.ZodObject<{ - src: z.ZodString; - width: z.ZodNumber; - height: z.ZodNumber; - format: z.ZodUnion< - [ - z.ZodLiteral<'png'>, - z.ZodLiteral<'jpg'>, - z.ZodLiteral<'jpeg'>, - z.ZodLiteral<'tiff'>, - z.ZodLiteral<'webp'>, - z.ZodLiteral<'gif'>, - z.ZodLiteral<'svg'>, - ] - >; -}>; - export function docsSchema() { - return ({ image }: { image: ImageFunction }) => + return ({ image }: SchemaContext) => z.object({ /** The title of the current page. Required. */ title: z.string(), |