How it works

How content gets from a source to your app.

Comark Content is a small layer between your content and your app. It reads files from a source, parses each one with Comark, indexes them and serves them through a typed API.

Start with the essentials

content.ts
import { comarkContent } from 'comark-content'
import fs from 'comark-content/sources/fs'

export const content = comarkContent({
  source: fs('./content'),
})
  1. Source loads raw keys and their contents (keys(), getItem()).
  2. Manifest is an in-memory index of every entry by path, so lookups and listings hit RAM, never the source.
  3. Parse happens on get() and turns each Markdown file into an object.
  4. Cache keeps each parsed body so the next get() skips the parse. It's in-memory by default, so this works with zero setup.
  5. Client exposes the result through get(), list(), navigation(), and handler().

Add layers as you grow

These optional layers speed up reads and add capabilities:

LayerRoleDefault
CacheStore parsed bodies so reads stay cheapIn-memory, on
DatabaseBack the SQL query and search pluginsOff
PluginsAdd parsers, queries, search, mediaNone