You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/en/guides/content-collections.mdx
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -132,8 +132,9 @@ Each individual collection configures:
132
132
-[a build-time `schema`](#defining-the-collection-schema) for type safety (optional, but highly recommended!)
133
133
134
134
```ts title="src/content.config.ts"
135
-
// 1. Import utilities from `astro:content`
136
-
import { defineCollection, z } from'astro:content';
135
+
// 1. Import utilities from `astro:content` and `astro/zod`
136
+
import { defineCollection } from'astro:content';
137
+
import { z } from'astro/zod';
137
138
138
139
// 2. Import loader(s)
139
140
import { glob } from'astro/loaders';
@@ -332,7 +333,8 @@ In order for Astro to recognize a new or updated schema, you may need to restart
332
333
Providing a `schema` is optional, but highly recommended! If you choose to use a schema, then every frontmatter or data property of your collection entries must be defined using a [Zod data type](#defining-datatypes-with-zod):
333
334
334
335
```ts title="src/content.config.ts" {6-11,15-19}
335
-
import { defineCollection, z } from'astro:content';
Astro uses [Zod](https://github.com/colinhacks/zod) to power its content schemas. With Zod, Astro is able to validate every file's data within a collection *and* provide automatic TypeScript types when you query content from inside your project.
362
364
363
-
To use Zod in Astro, import the `z` utility from `"astro:content"`. This is a re-export of the Zod library, and it supports all of the features of Zod 3.
365
+
To use Zod in Astro, import the `z` utility from `"astro/zod"`. This is a re-export of the Zod library, and it supports all of the features of Zod 3.
364
366
365
367
```ts
366
368
// Example: A cheatsheet of many common Zod datatypes
Copy file name to clipboardExpand all lines: src/content/docs/en/guides/integrations-guide/mdx.mdx
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,7 +101,8 @@ It also adds extra features to standard MDX, including support for Markdown-styl
101
101
To include your local MDX files in a content collection, make sure that your [collection loader](/en/guides/content-collections/#build-time-collection-loaders) is configured to load content from `.mdx` files:
102
102
103
103
```js title="src/content.config.ts" ins="mdx"
104
-
import { defineCollection, z } from'astro:content';
In Astro 5.x, `astro:schema` was introduced as an alias of `astro/zod`. `z` was also exported from `astro:content` for convenience. However this occasionally created confusion for users who were unsure about where they should be importing from.
163
+
164
+
Astro 6.0 deprecates `astro:schema` and `z` from `astro:content` in favor of `astro/zod`.
165
+
166
+
#### What should I do?
167
+
168
+
Replace any occurrences of `astro:schema` with `astro/zod`:
169
+
170
+
```ts del={1} ins={2}
171
+
import { z } from"astro:schema"
172
+
import { z } from"astro/zod"
173
+
```
174
+
175
+
Remove `z` from your `astro:content` imports and import `z` separately from `astro/zod` instead:
import { defineCollection, z } from"astro:content"
179
+
import { defineCollection } from"astro:content"
180
+
import { z } from"astro/zod"
181
+
```
182
+
<ReadMore>See more about [defining collection schemas with Zod](/en/guides/content-collections/#defining-datatypes-with-zod).</ReadMore>
158
183
## Removed
159
184
160
185
The following features have now been entirely removed from the code base and can no longer be used. Some of these features may have continued to work in your project even after deprecation. Others may have silently had no effect.
@@ -207,9 +232,10 @@ Rename and move this file to `src/content.config.ts`
207
232
208
233
Import [Astro's built-in `glob()` loader](/en/guides/content-collections/#the-glob-loader) and define the `pattern` and `base` for your collection entries:
209
234
210
-
```ts ins={3,6}
235
+
```ts ins={4,7}
211
236
// src/content.config.ts
212
-
import { defineCollection, z } from 'astro:content';
237
+
import { defineCollection } from 'astro:content';
238
+
import { z } from 'astro/zod';
213
239
import { glob } from 'astro/loaders';
214
240
215
241
const blog = defineCollection({
@@ -228,9 +254,10 @@ const blog = defineCollection({
228
254
<summary>a collection that defines a collection type (`type: 'content'` or `type: 'data'`) / ([`ContentCollectionInvalidTypeError`](/en/reference/errors/content-collection-invalid-type/))</summary>
229
255
There are no longer different types of collections. This must be deleted from your collection definition.
230
256
231
-
```ts del={7}
257
+
```ts del={8}
232
258
// src/content.config.ts
233
-
import {defineCollection, z} from 'astro:content';
0 commit comments