summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/blog/src/content/config.ts10
-rw-r--r--packages/astro/test/fixtures/content-ssr-integration/src/content/config.ts7
-rw-r--r--packages/astro/test/fixtures/content-static-paths-integration/src/content/config.ts7
3 files changed, 6 insertions, 18 deletions
diff --git a/examples/blog/src/content/config.ts b/examples/blog/src/content/config.ts
index b4e86c9f7..f0419223e 100644
--- a/examples/blog/src/content/config.ts
+++ b/examples/blog/src/content/config.ts
@@ -6,14 +6,8 @@ const blog = defineCollection({
title: z.string(),
description: z.string(),
// Transform string to Date object
- pubDate: z
- .string()
- .or(z.date())
- .transform((val) => new Date(val)),
- updatedDate: z
- .string()
- .optional()
- .transform((str) => (str ? new Date(str) : undefined)),
+ pubDate: z.coerce.date(),
+ updatedDate: z.coerce.date().optional(),
heroImage: z.string().optional(),
}),
});
diff --git a/packages/astro/test/fixtures/content-ssr-integration/src/content/config.ts b/packages/astro/test/fixtures/content-ssr-integration/src/content/config.ts
index d22a45648..8d68c0ec3 100644
--- a/packages/astro/test/fixtures/content-ssr-integration/src/content/config.ts
+++ b/packages/astro/test/fixtures/content-ssr-integration/src/content/config.ts
@@ -4,11 +4,8 @@ const blog = defineCollection({
schema: z.object({
title: z.string(),
description: z.string(),
- pubDate: z.string().transform((str) => new Date(str)),
- updatedDate: z
- .string()
- .optional()
- .transform((str) => (str ? new Date(str) : undefined)),
+ pubDate: z.coerce.date(),
+ updatedDate: z.coerce.date().optional(),
heroImage: z.string().optional(),
}),
});
diff --git a/packages/astro/test/fixtures/content-static-paths-integration/src/content/config.ts b/packages/astro/test/fixtures/content-static-paths-integration/src/content/config.ts
index d22a45648..8d68c0ec3 100644
--- a/packages/astro/test/fixtures/content-static-paths-integration/src/content/config.ts
+++ b/packages/astro/test/fixtures/content-static-paths-integration/src/content/config.ts
@@ -4,11 +4,8 @@ const blog = defineCollection({
schema: z.object({
title: z.string(),
description: z.string(),
- pubDate: z.string().transform((str) => new Date(str)),
- updatedDate: z
- .string()
- .optional()
- .transform((str) => (str ? new Date(str) : undefined)),
+ pubDate: z.coerce.date(),
+ updatedDate: z.coerce.date().optional(),
heroImage: z.string().optional(),
}),
});