Content Collections
Astro Content Collections load local content and validate frontmatter with schemas. In modern Astro projects, src/content.config.ts defines collections through the Content Layer API.
Role of src/content.config.ts
Section titled “Role of src/content.config.ts”This file defines the collections, loaders, and schema validation used by the theme. For Verdict Law, it should define collections for attorneys, blog articles, and practice areas.
Why Validation Matters
Section titled “Why Validation Matters”Invalid frontmatter can fail the build. This is useful because broken content is caught before deployment.
Common validation failures include:
- Missing required fields.
- Wrong date format.
- Incorrect image value.
- Invalid reference slug.
- Boolean fields written as strings.
Slugs and Dynamic Routes
Section titled “Slugs and Dynamic Routes”Collection entries are queried by pages such as src/pages/attorneys/[slug].astro, src/pages/practice-areas/[slug].astro, and src/pages/insights/[slug].astro. The slug is usually derived from the entry ID or file path, but the exact behavior depends on the loader.
Querying Collections
Section titled “Querying Collections”Astro pages can query entries with APIs from astro:content.
Example only:
import { getCollection } from 'astro:content';
const attorneys = await getCollection('attorneys');Confirm the real collection names in src/content.config.ts.