use-content-collections-for-markdown
Installation
SKILL.md
Summary
Use Astro's Content Collections (src/content) for managing Markdown/MDX types. Define strict schemas using Zod in src/content/config.ts. Avoid placing content directly in src/pages.
Rationale
- Type Safety: Content Collections generate TypeScript interfaces for frontmatter, preventing runtime errors.
- Validation: Zod schemas ensure all content meets requirements (e.g. valid dates, required images).
- Separation: Decouples content structure from routing logic.
Guidance
- Define Schema: Always create a
config.tsinsrc/contentand define a schema for each collection. - Query, Don't Import: Use
getCollection()to fetch content, notimport * from '*.md'.