CLI

The comark-content binary — locate your Content config and generate source types.

comark-content ships a small CLI binary, comark-content, installed alongside the package. It currently has one subcommand.

Terminal
npx comark-content --help

comark-content prepare

Locates your comarkContent() instance and generates source types (comark-content.d.ts by default). This is the same writeSourceTypes() the Vite plugin runs automatically — reach for the CLI when you're not using Vite, or want to (re)generate types as a standalone script or CI step.

Terminal
npx comark-content prepare

Config discovery:

Without --config, it searches for content.{ts,mts,js,mjs} in, relative to --cwd:

  • .
  • ./server
  • ./lib
  • ./server/utils
  • ./server/lib

The first match is loaded (via jiti) and its exported Content instance resolved by checking, in order: the default export, a content export, then any other exported value that looks like a ComarkContent. Export it explicitly if discovery doesn't find it:

content.ts
export const content = comarkContent({ /* ... */ })

Flags:

FlagTypeDefaultDescription
--cwd <dir>stringprocess.cwd()Project directory to search and resolve paths from.
--config <path/to/content.ts>stringPath to the Content instance file, bypassing directory search.
--output <file>, -ostringcomark-content.d.tsWhere to write the generated types.
--module-name <name>stringcomark-contentModule specifier the declare module augmentation targets.
--paths / --no-pathsbooleantrueEmit the per-document ContentPaths map. Pass --no-paths to skip it on very large sites.

Errors:

  • No content.{ts,mts,js,mjs} found in any searched directory: exits 1 and prints the directories searched. Pass --config to point at it explicitly.
  • The resolved config path doesn't exist, or doesn't export a Content instance: exits 1 with a message telling you to export const content = comarkContent({ ... }).

Usage:

# Default: search for content.ts, write ./comark-content.d.ts
comark-content prepare

# Explicit config and output path
comark-content prepare --config server/content.ts --output types/comark-content.d.ts

# Skip the ContentPaths map on a large site
comark-content prepare --no-paths

When writing to the default comark-content.d.ts, the command reminds you to add it to .gitignore and to your tsconfig.json include — see Type Safety.