Build CLI (onto-next)
Compiles your Next.js pages into clean Markdown at build time.
What it does
Runs after next build (when wired into your package.json as next build && onto-next). It walks your compiled HTML output, runs each page through the cleaning engine (@ontosdk/core), and writes per-route .md files into public/.onto/.
Build-time, not request-time. Markdown extraction happens once per deploy — no per-request CPU cost. The middleware just streams pre-built files at runtime (plus optional context injection).
Build output
bash
$ npm run build
> next build && onto-next
[Next] Compiled successfully
[Onto] Processed 12 pages. Total size: 4.2MB → 38.1KB
[Onto] Syncing manifest with Control Plane [https://api.buildonto.dev]...
[Onto] ✓ Control Plane sync successful (12 files)What gets extracted
| Element | Behaviour |
|---|---|
| Headings (h1–h6) | Preserved as Markdown headings with corrected hierarchy. |
| Paragraphs | Plain text with whitespace normalized. |
| Links | Markdown link syntax with absolute hrefs. |
| Lists, tables | Native Markdown equivalents. |
| Code blocks | Preserved with language hints when detected. |
| JSON-LD | Extracted from <script type='application/ld+json'> and preserved as a fenced block. |
| Metadata | Title + description + language pulled from <head>. |
| Tailwind / styles | Stripped — no class attributes survive. |
| JS bundles, hydration | Stripped — only the rendered HTML matters. |
| Tracking pixels, analytics | Stripped. |
Control Plane sync
When ONTO_API_KEY is set, the CLI also POSTs the manifest to /api/files on the Control Plane. Each manifest entry includes route, filename, content, html_bytes, markdown_bytes, sdkVersion. The dashboard's /serve/routes page reads from this — it's how you preview exactly what bots receive after each deploy.
If the CLI says "Control Plane sync skipped": check
ONTO_API_KEY is set in your build env and ONTO_API_URL (if overridden) is reachable from the build worker. Sync failure is non-fatal — your .md files still generate; the dashboard just won't see them.