@comark/cms
v0.1.0
Published
Content management system for Comark
Downloads
32
Readme
@comark/cms
Universal content layer for Markdown-driven websites. Comark CMS turns Markdown from the filesystem, GitHub, or any storage driver into a queryable, searchable, type-safe API. Framework-agnostic, it runs on a server, at the edge, or fully in the browser. Built on Comark.
Why Comark CMS
- Runtime, not build-time: content is read from the source when your app asks. Push Markdown, it's live on the next request — no rebuild, no redeploy.
- Lightweight core: four methods —
get,list,navigation,watch. Everything else is an opt-in plugin. - Pluggable sources: filesystem, GitHub, or any unstorage driver (S3, KV, Redis, HTTP).
- Type-safe: generated types narrow
get(),list(), andquery()by source and by path. - SQL queries & full-text search: opt into a SQLite-backed query builder and BM25 search over frontmatter and content.
- Runs anywhere: Node, edge, or fully in the browser with a hydrated snapshot.
- Framework-agnostic: returns a plain Comark AST, rendered by Vue, React, Svelte, Angular, or plain HTML.
Quick start
pnpm add @comark/cmsimport { createCMS } from '@comark/cms'
import fs from '@comark/cms/sources/fs'
export const cms = createCMS({
source: fs('./content'),
})
const page = await cms.get('/getting-started/introduction')
const nav = await cms.navigation()Swap the source for GitHub, or any unstorage driver — same API:
import github from '@comark/cms/sources/github'
const cms = createCMS({
source: github({ repo: 'nuxt/nuxt', branch: 'main', path: 'docs' }),
})Type-safe by generation
Run the CLI (or the Vite plugin) to generate types from your actual content. It infers a schema per source and augments @comark/cms, so reads narrow to the real shape of your files:
npx comark-cms prepare # writes comark-cms.d.ts// `/about` is a known path — it autocompletes, and `data` is typed from its frontmatter
const about = await cms.get('/about')
about?.data.title // string
// passing source names narrows each item's `data`
const posts = await cms.list(['blog']) // data: BlogData
No casts, no manual interfaces — edit a file, re-run `prepare`, and the types follow.
## CLI
The package ships a small `comark-cms` binary. Today it has a single focused command, `prepare`, which locates your `createCMS()` instance and generates source types — the same generation the Vite plugin runs automatically. Reach for it when you're not using Vite, or want to (re)generate types in a script or CI step.
```sh
npx comark-cms prepare # find cms.{ts,mts,js,mjs}, write ./comark-cms.d.ts
npx comark-cms prepare --config server/cms.ts -o types/comark-cms.d.ts
npx comark-cms --helpSee the CLI reference for all flags.
Documentation
Full guides, concepts, and API reference at cms.comark.dev.
License
Made with ❤️
Published under MIT License.
