Node
Use Comark Content from a plain Node script.
No framework, no server: a Node script imports the instance and reads content in-process. This is the shape for static site generators, build scripts, migrations, or feeding content to an LLM pipeline.
Install the package
pnpm add comark-contentnpm install comark-contentyarn add comark-contentbun add comark-contentCreate the Content instance
content.ts
import { comarkContent } from 'comark-content'
import fs from 'comark-content/sources/fs'
export const content = comarkContent({
source: fs('./content'),
})Read your content
Every read initialises the manifest lazily on first call — there is no build step:
index.ts
import { content } from './content'
// One entry, body parsed to a MarkdownDocument
const page = await content.get('/')
console.log(page?.data.title, page?.nodes.length)
// Frontmatter of every entry, no body parse
const items = await content.list()
// The navigation tree
const nav = await content.navigation()Optional: SQL queries and search
Back the SQL query and full-text search plugins with the Node SQLite database:
content.ts
import { comarkContent } from 'comark-content'
import fs from 'comark-content/sources/fs'
import sqlite from 'comark-content/database/sqlite-node'
import sqlQuery from 'comark-content/plugins/sql-query'
import sqliteFullTextSearch from 'comark-content/plugins/sqlite-full-text-search'
const database = sqlite()
export const content = comarkContent({
source: fs('./content'),
plugins: [sqlQuery({ database }), sqliteFullTextSearch({ database })],
})index.ts
const drafts = await content.query('default').where('data.draft', '=', true).all()
const hits = await content.search(['default'], 'content layer', { limit: 5 })Generate source types
Type content.get() and content.query() from your frontmatter by generating source types:
Terminal
npx comark-content prepareAdd comark-content.d.ts to your tsconfig.json include — see Type Safety.