Introduction
Comark Content is a small, framework-agnostic content layer built on top of Comark. It turns Markdown from anywhere (your local files, a GitHub repo, or any storage driver) into a queryable, searchable, type-safe API.
You wire it once, with no folder convention, no framework lock-in, and no build step. The same instance runs on a Node server, at the edge, or entirely in the browser.
import { comarkContent } from 'comark-content'
import fs from 'comark-content/sources/fs'
export const content = comarkContent({
// Sourcing Markdown from the filesystem
source: fs('./content'),
})
const page = await content.get('/getting-started/introduction')What it does
Comark Content sits between your content and your app, and does three things:
- Loads Markdown from a source: filesystem, GitHub, or any unstorage driver.
- Parses each file with Comark: frontmatter up front to index it, the body into a structured AST on demand.
- Serves the result through a small, typed API:
get,list,navigation, as well as optional SQLquery()and full-textsearch().
Comark x Comark Content
Comark and Comark Content are two layers of the same stack.
Comark is used for the Markdown parser and renderer, where Comark Content is the content layer built on top of them.
| Comark | Comark Content | |
|---|---|---|
| Role | Markdown-with-components syntax, parser, and renderers | Content layer over a collection of files |
| Input | A Markdown string | A whole source: filesystem, GitHub, or unstorage |
| Output | A parsed MarkdownDocument, or rendered UI | Typed get, list, navigation, SQL, and search |
| Scope | One document at a time | A source of many documents |
Comark handles a single document end to end: it parses one Markdown file into a structured MarkdownDocument and renders it through the <MarkdownDocument> component provided for any frontend framework (Angular, Svelte, React and Vue).
Comark Content works one level up: it sources many files, parses each one with Comark, and serves the results through a queryable, type-safe API.
Features
Everything you need for a content layer, all opt-in:
Framework-agnostic
Pluggable sources
Type-safe
content.get() and content.query() by source and by path.SQL and full-text search
Runs in the browser
sqlite-wasm.Streaming-aware
Architecture
Comark Content is a pipeline with two read paths. Building the manifest parses frontmatter only: a lightweight index that backs list and navigation. Each document body is parsed into an AST lazily, the first time you get() it; the optional cache keeps that parsed result so later reads skip the parse.
Everything after the source is optional, so the Content instance stays as small as one source and a get(), or grows into caching, SQL, and search as you need it.
| Concept | Required | Role | Examples |
|---|---|---|---|
| Source | Where files come from | fs(), github(), unstorageSource() | |
| Cache | Where parsed entries are stored and kept fresh | in-memory (default), any unstorage driver | |
| Database | Backs the SQL query and full-text search plugins | sqlite(), sqliteWasm() | |
| Plugin | Extra capabilities | sqlQuery, sqliteFullTextSearch, media, json, yaml |
Compare
How Comark Content relates to the tools it replaces: