Collections API
Typed content collections with zod schemas
defineCollection and defineCollections provide typed collection loaders over .mdx files.
DefineCollection
Create one typed collection.
DefineCollections
Create multiple collections in one call.
Returned API
Collection instances expose:
getAll()get(slug)count()filter(fn)sort(key, order?)wherekeyisslugor a scalar schema field
Type inference
Schema fields are inferred through zod.
Notes
- Files are scanned recursively under
dir - Slugs are file-path based (
nested/page.mdx->nested/page) - Frontmatter is validated with
schema.parse