From 72fed684a35f00d80c69bcf6e8af297fed0294fe Mon Sep 17 00:00:00 2001 From: Xetera Date: Thu, 6 Apr 2023 14:58:34 +0300 Subject: [PATCH] Exporting ImageFunction from astro:content (#6766) --- .changeset/big-poems-march.md | 5 +++++ packages/astro/src/content/template/types.d.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/big-poems-march.md diff --git a/.changeset/big-poems-march.md b/.changeset/big-poems-march.md new file mode 100644 index 000000000..a53224c62 --- /dev/null +++ b/.changeset/big-poems-march.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Exporting the ImageFunction in astro:content and grouping it under a SchemaContext diff --git a/packages/astro/src/content/template/types.d.ts b/packages/astro/src/content/template/types.d.ts index 346d3ff95..28da29ce1 100644 --- a/packages/astro/src/content/template/types.d.ts +++ b/packages/astro/src/content/template/types.d.ts @@ -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; + export type SchemaContext = { image: ImageFunction }; + type BaseCollectionConfig = { - schema?: S | (({ image }: { image: ImageFunction }) => S); + schema?: S | ((context: SchemaContext) => S); slug?: (entry: { id: CollectionEntry['id']; defaultSlug: string;