Skip to content

Commit

Permalink
Exporting ImageFunction from astro:content (#6766)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xetera authored Apr 6, 2023
1 parent c4d94d5 commit 72fed68
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/big-poems-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Exporting the ImageFunction in astro:content and grouping it under a SchemaContext
6 changes: 4 additions & 2 deletions packages/astro/src/content/template/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 72fed68

Please sign in to comment.