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

Replace copy/pasted ImageFunction with imported SchemaContext #775

Merged
merged 4 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading