summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Xetera <contact@xetera.dev> 2023-04-06 14:58:34 +0300
committerGravatar GitHub <noreply@github.com> 2023-04-06 13:58:34 +0200
commit72fed684a35f00d80c69bcf6e8af297fed0294fe (patch)
treef9f187253f8c1fdcfb3a2a1b869ec6b2ec441a92
parentc4d94d5ca167a010a8baf4ce52186824a49f8753 (diff)
downloadastro-72fed684a35f00d80c69bcf6e8af297fed0294fe.tar.gz
astro-72fed684a35f00d80c69bcf6e8af297fed0294fe.tar.zst
astro-72fed684a35f00d80c69bcf6e8af297fed0294fe.zip
Exporting ImageFunction from astro:content (#6766)
-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;