til
Zod validates my blog's frontmatter
Astro’s content collections run every post’s frontmatter through a Zod schema at build time. Misspell date or write an impossible one, and the build fails with a pointed error instead of silently publishing a broken note.
schema: z.object({
title: z.string(),
date: z.coerce.date(),
type: z.enum(['til', 'blog']).default('blog'),
})
The z.coerce.date() is the quiet hero: it accepts 2026-06-28, a full ISO timestamp, or anything else new Date() understands.