astro/.changeset/many-dancers-fold.md
Erika a1108e0371
Move image() to be passed as part of schema (#6703)
* feat(images): Move image() to schema so we can do relative images easily instead of clumsily

* chore: changeset

* fix: apply feedback

* test: add more tests

* fix: properly infer type if a function is used

* feat(iamge): Add errors when using the old methods

* chore: update to minor

* feat(image): Move function shape to be experimental.asets only

* Update packages/astro/src/content/template/virtual-mod.mjs

Co-authored-by: Ben Holmes <hey@bholmes.dev>

---------

Co-authored-by: Ben Holmes <hey@bholmes.dev>
2023-04-05 15:40:05 +02:00

495 B

astro
minor

Move image() to come from schema instead to fix it not working with refine and inside complex types

Migration:

Remove the image import from astro:content, and instead use a function to generate your schema, like such:

import { defineCollection, z } from "astro:content";

defineCollection({
  schema: ({ image }) =>
    z.object({
      image: image().refine((img) => img.width >= 200, {
        message: "image too small",
      }),
    }),
});