summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/big-poems-march.md5
-rw-r--r--packages/astro/src/content/template/types.d.ts6
2 files changed, 9 insertions, 2 deletions
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<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;