How to build a typed content collection with a Zod frontmatter schema in Astro
Define an Astro content collection with a Zod schema so every post's frontmatter is validated at build time and fully typed in your editor.
5 posts
Define an Astro content collection with a Zod schema so every post's frontmatter is validated at build time and fully typed in your editor.
Astro 7 ships a new default Markdown processor. Here's why you'd override it with unified() to register your own remark and rehype plugins, and how remarkPlugins, rehypePlugins, and shikiConfig fit together.
Wrap every Shiki code block in a toolbar with a language label, a copy button, and a fullscreen button — emitted at build time by a rehype plugin so there's no layout shift and it works before JavaScript loads.
Build a tiny remark plugin that counts the words in a Markdown post and exposes a '4 min read' estimate on Astro's frontmatter — grounded in real, working code.
Astro's built-in Shiki highlighter treats a mermaid fence as code and syntax-highlights it. Here's how a tiny remark plugin rewrites that fence before Shiki sees it, so a client runtime can turn it into a real diagram.