1import { defineCollection, z } from 'astro:content'; 2 3const blog = defineCollection({ 4 // Type-check frontmatter using a schema 5 schema: z.object({ 6 title: z.string(), 7 author: z.string(), 8 description: z.string().optional(), 9 // Transform string to Date object 10 date: z 11 .string() 12 .or(z.date()) 13 .transform((val) => new Date(val)), 14 updatedDate: z 15 .string() 16 .optional() 17 .transform((str) => (str ? new Date(str) : undefined)), 18 image: z.string().optional(), 19 tags: z.array(z.string()).optional(), 20 draft: z.boolean().optional(), 21 }), 22}); 23 24export const collections = { blog };