Exporting ImageFunction from astro:content (#6766)

This commit is contained in:
Xetera 2023-04-06 14:58:34 +03:00 committed by GitHub
parent c4d94d5ca1
commit 72fed684a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Exporting the ImageFunction in astro:content and grouping it under a SchemaContext

View file

@ -33,7 +33,7 @@ declare module 'astro:content' {
export const image: never;
// This needs to be in sync with ImageMetadata
type ImageFunction = () => import('astro/zod').ZodObject<{
export type ImageFunction = () => import('astro/zod').ZodObject<{
src: import('astro/zod').ZodString;
width: import('astro/zod').ZodNumber;
height: import('astro/zod').ZodNumber;
@ -63,8 +63,10 @@ declare module 'astro:content' {
| BaseSchemaWithoutEffects
| import('astro/zod').ZodEffects<BaseSchemaWithoutEffects>;
export type SchemaContext = { image: ImageFunction };
type BaseCollectionConfig<S extends BaseSchema> = {
schema?: S | (({ image }: { image: ImageFunction }) => S);
schema?: S | ((context: SchemaContext) => S);
slug?: (entry: {
id: CollectionEntry<keyof typeof entryMap>['id'];
defaultSlug: string;