Notes

Astro Content Collections Notes

Working notes on Astro Content Collections patterns and gotchas.

Astro Content Collections provide type-safe content management. Define a schema with Zod, and Astro validates all frontmatter at build time.

Key points

  • Use src/content.config.ts for collection definitions
  • defineCollection with glob() loader for file-based content
  • Schema validation happens at build time, catching frontmatter errors early
  • getCollection() returns typed entries in .astro files
  • Draft filtering must be explicit in route code