Exporting ImageFunction from astro:content (#6766)
This commit is contained in:
parent
c4d94d5ca1
commit
72fed684a3
2 changed files with 9 additions and 2 deletions
5
.changeset/big-poems-march.md
Normal file
5
.changeset/big-poems-march.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Exporting the ImageFunction in astro:content and grouping it under a SchemaContext
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue