Contentbase (v0.4.1) is an ESM-only TypeScript library that treats a folder of Markdown/MDX files as a typed, queryable database. Define models with Zod schemas for frontmatter validation, extract structured data from headings and lists, traverse parent/child relationships across documents, and query with a fluent API. It requires Node 18+ or Bun and ships with full TypeScript inference. Unlike static site generators or CMS tools, Contentbase provides an ORM-like experience directly on flat files without any database or build step.
npm install contentbaseNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Defines a Story model with Zod-validated frontmatter, extracts acceptance criteria from a list section, loads content from './content', and queries for ready stories.
Upgrade to Node 18+ or use Bun.
Use import syntax and ensure your project is configured for ESM (e.g., "type": "module" in package.json).
Provide default values in your Zod schema using .default() to avoid failures for optional fields.
Ensure heading strings in section() match exactly the Markdown heading, including trailing spaces or punctuation.
Always provide a prefix that matches your content directory structure.
Change to import { Collection } from 'contentbase' and add "type": "module" to package.json.Add .default() to the Zod schema for optional fields, e.g., z.enum(['draft', 'ready']).default('draft').Verify the heading text in section() matches exactly the heading in your Markdown (case-sensitive).
Place your Markdown files in a directory matching the model prefix, e.g., ./content/stories/mystory.md.