0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00
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

22 lines
495 B
Markdown

---
'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:
```ts
import { defineCollection, z } from "astro:content";
defineCollection({
schema: ({ image }) =>
z.object({
image: image().refine((img) => img.width >= 200, {
message: "image too small",
}),
}),
});
```