diff options
author | 2023-09-04 11:46:24 +0100 | |
---|---|---|
committer | 2023-09-04 18:46:24 +0800 | |
commit | 77922ae5db5f40b8e228337b56af44d7c98bafbc (patch) | |
tree | 04e9cc776addfb9423ae2c2768615a1d9b304376 /examples/blog/src | |
parent | 535a4589998041cf2e3dfcac462a51479c1d13a3 (diff) | |
download | astro-77922ae5db5f40b8e228337b56af44d7c98bafbc.tar.gz astro-77922ae5db5f40b8e228337b56af44d7c98bafbc.tar.zst astro-77922ae5db5f40b8e228337b56af44d7c98bafbc.zip |
chore: use `z.coerce.date()` to pass input through `new Date(input)`. (#8383)
Diffstat (limited to 'examples/blog/src')
-rw-r--r-- | examples/blog/src/content/config.ts | 10 |
1 files changed, 2 insertions, 8 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(), }), }); |