Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/social-maps-shine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': major
---

Deprecates `astro:schema` and `z` from `astro:content` in favor of `astro/zod` - ([v6 upgrade guidance](https://deploy-preview-12322--astro-docs-2.netlify.app/en/guides/upgrade-to/v6/#deprecated-astroschema-and-z-from-astrocontent))
3 changes: 2 additions & 1 deletion benchmark/make-project/markdown-cc1.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ const { Content } = await render(entry);
await fs.writeFile(
new URL(`./src/content.config.ts`, projectDir),
`\
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const blog = defineCollection({
Expand Down
3 changes: 2 additions & 1 deletion benchmark/make-project/markdown-cc2.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ ${loremIpsumMd}
await fs.writeFile(
new URL(`./src/content.config.ts`, projectDir),
/*ts */ `
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const blog = defineCollection({
Expand Down
3 changes: 2 additions & 1 deletion benchmark/make-project/mdx-cc1.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ const { Content } = await render(entry);
await fs.writeFile(
new URL(`./src/content.config.ts`, projectDir),
`\
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const blog = defineCollection({
Expand Down
4 changes: 2 additions & 2 deletions benchmark/make-project/mdx-cc2.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ ${loremIpsumMd}
await fs.writeFile(
new URL(`./src/content.config.ts`, projectDir),
/*ts */ `
import { defineCollection, z } from 'astro:content';
import { glob } from 'astro/loaders';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';

const blog = defineCollection({
loader: glob({ pattern: '*', base: './data/blog' }),
Expand Down
3 changes: 2 additions & 1 deletion benchmark/make-project/memory-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ const { Content } = await render(entry);
await fs.writeFile(
new URL(`./src/content.config.ts`, projectDir),
`\
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const blog = defineCollection({
Expand Down
3 changes: 2 additions & 1 deletion examples/blog/src/content.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { glob } from 'astro/loaders';
import { z } from 'astro/zod';

const blog = defineCollection({
// Load Markdown and MDX files in the `src/content/blog/` directory.
Expand Down
3 changes: 2 additions & 1 deletion examples/portfolio/src/content.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { glob } from 'astro/loaders';
import { z } from 'astro/zod';

export const collections = {
work: defineCollection({
Expand Down
3 changes: 2 additions & 1 deletion examples/starlog/src/content.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { glob } from 'astro/loaders';
import { z } from 'astro/zod';

const releases = defineCollection({
// Load Markdown files in the src/content/releases directory.
Expand Down
14 changes: 14 additions & 0 deletions packages/astro/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,22 @@ declare module 'astro:components' {
export * from 'astro/components';
}

// TODO: remove in Astro 7
/**
* @deprecated
* `import { z } from 'astro:schema'` is deprecated and will be removed
* in Astro 7. Use `import { z } from 'astro/zod'` instead.
*/
declare module 'astro:schema' {
export * from 'astro/zod';
import zod from 'astro/zod';

/**
* @deprecated
* `import { z } from 'astro:schema'` is deprecated and will be removed
* in Astro 7. Use `import { z } from 'astro/zod'` instead.
*/
export const z = zod.z;
}

type MD = import('./dist/types/public/content.js').MarkdownInstance<Record<string, any>>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { db, Comment, Likes, eq, sql } from 'astro:db';
import { ActionError, defineAction } from 'astro:actions';
import { z } from 'astro:schema';
import { z } from 'astro/zod';
import { getCollection } from 'astro:content';

export const server = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const blog = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { db, Likes, eq, sql } from 'astro:db';
import { defineAction, type SafeResult } from 'astro:actions';
import { z } from 'astro:schema';
import { z } from 'astro/zod';
import { getActionState } from '@astrojs/react/actions';

export const server = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const blog = defineCollection({
Expand Down
1 change: 1 addition & 0 deletions packages/astro/src/core/create-vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export async function createVite(
find: 'astro:middleware',
replacement: 'astro/virtual-modules/middleware.js',
},
// TODO: remove in Astro 7
{
find: 'astro:schema',
replacement: 'astro/zod',
Expand Down
1 change: 1 addition & 0 deletions packages/astro/templates/content/module.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export {
defineLiveCollection,
renderEntry as render,
} from 'astro/content/runtime';
// TODO: remove in Astro 7
export { z } from 'astro/zod';

/* @@LIVE_CONTENT_CONFIG@@ */
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/test/fixtures/actions/src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineAction, ActionError } from 'astro:actions';
import { z } from 'astro:schema';
import { z } from 'astro/zod';

const passwordSchema = z
.string()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from "astro:content";
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from "astro/loaders";

const blogCollection = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from "astro:content";
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from "astro/loaders";

const blogCollection = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from "astro:content";
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { FOO } from "astro:env/client"

console.log({ FOO, BAR: import.meta.env.BAR })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const withCustomSlugs = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, reference, z } from 'astro:content';
import { defineCollection, reference } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const banners = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const blog = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const blog = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const blog = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// 1. Import utilities from `astro:content`
import { z, defineCollection } from "astro:content";
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from "astro/loaders";

// 2. Define a `type` and `schema` for each collection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';

const data = defineCollection({
loader: async () => ([
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const blog = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const withData = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { glob, file } from 'astro/loaders';
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';

const blogCC = defineCollection({
loader: glob({ pattern: "**/*.{md,mdx,mdoc}", base: "./src/content/blog-cc" }),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const docs = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z, reference } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const reptiles = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z, reference } from 'astro:content';
import { defineCollection, reference } from 'astro:content';
import { z } from 'astro/zod';
import { file, glob } from 'astro/loaders';
import { loader } from './loaders/post-loader.js';
import { readFile } from 'fs/promises';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { z } from 'astro:content';
import { z } from 'astro/zod';
import type { Loader } from "astro/loaders"

export interface PostLoaderConfig {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const blog = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const blog = defineCollection({
Expand Down
3 changes: 2 additions & 1 deletion packages/astro/test/fixtures/content/src/content.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const blog = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from "astro:content";
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from "astro/loaders";

const blogCollection = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const blog = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from "astro:content";
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from "astro/loaders";

const blogCollection = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from "astro:content";
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from "astro/loaders";

const blogCollection = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const blog = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from "astro:content";
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from "astro/loaders";

const blogCollection = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const docs = defineCollection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const docs = defineCollection({
Expand Down
3 changes: 2 additions & 1 deletion packages/astro/test/fixtures/live-loaders/src/live.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineLiveCollection, z } from 'astro:content';
import { defineLiveCollection } from 'astro:content';
import { z } from 'astro/zod';
import type { LiveLoader } from 'astro/loaders';

type Entry = {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/test/fixtures/sessions/src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineAction } from 'astro:actions';
import { z } from 'astro:schema';
import { z } from 'astro/zod';

export const server = {
addToCart: defineAction({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ describe('frontmatter', () => {
---
`,
'/src/content.config.ts': `\
import { defineCollection, z } from 'astro:content';
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const posts = defineCollection({
Expand Down
Loading