Content Collections
A ReeWeb content collection is a folder of Markdown entries with a _schema.ts file. The schema validates each entry's frontmatter during a static build, so a missing title, malformed date, or incorrect author structure stops a broken content release before it reaches dist/.
There is no central registry. A folder becomes a collection as soon as it contains _schema.ts exporting a Zod schema.
Create a Collection
For a blog under src/public/blog/, add this file:
// src/public/blog/_schema.ts
import { z } from "$vendor/zod.min.js";
export const schema = z.object({
title: z.string().min(1),
published_at: z.coerce.date(),
description: z.string().min(1),
authors: z.array(z.union([
z.string(),
z.object({ name: z.string() }).passthrough(),
])).optional(),
}).passthrough();
Then give each Markdown entry frontmatter that satisfies it:
---
title: "A reliable build"
published_at: 2026-07-21
description: "Validate frontmatter before a static site ships."
authors:
- name: "Ada Lovelace"
---
z.coerce.date() accepts a normal YAML date or a date string. Use .optional() for fields that are not required on every entry. .passthrough() preserves framework and project-specific frontmatter keys instead of rejecting them.
What Is Validated
bun ssg discovers every _schema.ts under src/public/, imports its schema, then validates the Markdown records below that folder. A collection listing file at its own root, such as blog/index.md or blog/01_index.md, is excluded from entry validation. A nested blog/my-post/index.md is an entry and is validated.
All validation problems are collected before the build exits. This makes one repair pass possible instead of stopping at the first bad file.
Content collection validation failed:
blog/02_announcement.md: title: Required
blog/02_announcement.md: published_at: Invalid date
_schema.ts is build tooling only. It is not copied to dist/ and creates no runtime dependency; ReeWeb uses its vendored Zod copy at $vendor/zod.min.js.
Validate Without Building
An MCP client can run the read-only validate_content tool to check collection schemas and .ree/.md route collisions without creating a site build. See MCP Server.
For normal local and CI verification, run the production build:
bun ssg
The build exits non-zero when any collection entry violates its schema. Keep the schema next to the content it governs and version it together with the entries, so an editorial change and its constraints always travel together.
Collections, Listings, and Visibility
Collections validate content; they do not create an index page or automatically enable pagination. Use a sibling index.ree and, when needed, configure Pagination for the collection route.
The normal Content Visibility policy still applies after validation. Draft and future-dated posts may be valid collection entries while remaining out of listings, feeds, and the sitemap.