Seed & Bootstrap

Star-Lite Docs automatically creates the database schema and default content the first time your site receives a request.

How bootstrap works

On every request, Star-Lite's middleware calls ensurePagesCollection(). This function:

  1. Checks a module-level flag — if the seed has already been applied, it returns immediately
  2. Loads any user seed via emdash's virtual seed module and merges it with the default seed
  3. Calls applySeed() to create the pages collection and its fields
  4. Creates the docs-sidebar menu only if it doesn't already exist

The bootstrap is idempotent — existing collections, fields, and menus are never overwritten. Only missing pieces are added.

Default seed

The built-in seed (src/seed.ts) creates:

  • A pages collection with title (string, required, searchable) and content (portableText) fields
  • A docs-sidebar menu (empty items array)
  • A welcome page at slug index with a docs.hero block

Custom seed

The create-star-lite-docs CLI writes a .emdash/seed.json file with starter content and sidebar links. emdash exposes this via virtual:emdash/seed, and the bootstrap merges it with the default seed:

  • content from the user seed replaces the default content
  • menus from the user seed replaces the default menus
  • Collections and fields always come from the default seed

Programmatic access

  • defaultSeed — the SeedFile object shipped by the plugin (from src/seed.ts)
  • ensurePagesCollection(db) — the file-based bootstrap function (from src/bootstrap.ts). Note: the runtime middleware uses an inline version in the virtual module, not this export.