Skip to content

Commit

Permalink
Replace copy/pasted ImageFunction with imported SchemaContext (#775)
Browse files Browse the repository at this point in the history
* Replace copy/pasted `ImageFunction` with imported `SchemaContext`

* Only import type from astro:content

* Add changeset

* Improve changeset
  • Loading branch information
delucis authored Sep 27, 2023
1 parent 423d575 commit 2ef3036
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/fair-trains-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/starlight": patch
---

Fix content collection schema compatibility with Astro 3.1 and higher
20 changes: 2 additions & 18 deletions packages/starlight/schema.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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(),
Expand Down

0 comments on commit 2ef3036

Please sign in to comment.