Getting Started with Astro Content Collections
Demo Author
Astro Content Collections provide a built-in, type-safe way to manage your content. Define schemas with Zod, and Astro generates TypeScript types automatically.
Key Features
- Type Safety: Zod schemas validate your frontmatter at build time
- Auto-generated Types: TypeScript types are created from your schemas
- Markdown & MDX: First-class support for both formats
- Query API: Simple
getCollection()andgetEntry()functions
Usage
Define a collection in src/content.config.ts, create your content files, and query them in any .astro page.