Skip to main content
independoc
Language: English

CLI & API#

independoc can be invoked either from the command line or programmatically as a Node.js ESM module.

CLI Commands#

bash
independoc <command> [options]
CommandDescription
buildGenerate static site (HTML / CSS / JS / search index / sitemap.xml / llms.txt / 404.html)
serveStart local preview server with file watching and SSE live reload
checkValidate Markdown, duplicate routes, internal links, anchors, and nav without writing files
init [dir]Scaffold a minimal independoc.config.json and starter docs/ directory
version <name>Snapshot the current docsDir into versioned_docs/<name>/

Common Options#

OptionDefaultDescription
-c, --config <path>independoc.config.jsonPath to config file
-d, --docs <dir>docsSource Markdown directory
-o, --out <dir>distOutput directory
-b, --base <path>/Base URL path for sub-path deployment (e.g. /independoc/)
--site-url <url>config valueAbsolute site origin used for canonical, sitemap, and llms URLs
-p, --port <number>3000Dev server port
--host <address>127.0.0.1Dev server bind host (supports IPv6 such as ::1)
--include-draftsfalseInclude pages marked draft: true
--strict-linksfalseFail the build on broken links or anchors
-v, --version—Print version
-h, --help—Show help

Programmatic API (ESM)#

Invoke independoc directly from custom build scripts or CI tasks.

scripts/build-docs.mjs
import { buildSite, startDevServer, renderMarkdown } from 'independoc';

// 1. Static build
const result = await buildSite({
  cwd: process.cwd(),
  overrides: {
    basePath: '/independoc/',
    onBrokenLinks: 'error',
  },
});
console.log(`${result.pageCount} pages built in ${result.durationMs}ms`);

// 2. Standalone Markdown rendering
const { html, headings, customElements } = renderMarkdown('# Hello\n\n<nd-badge>Zero Dep</nd-badge>');
console.log({ headings, customElements, htmlLength: html.length });

Exported Functions#

  • buildSite(options) — Generate static site (write: false runs validation only)
  • startDevServer(options) — Start dev server (returns { server, url, port, close })
  • loadConfig(options) / normalizeBasePath(raw) / withBasePath(href, basePath) — Config and URL helpers
  • parseFrontmatter(source) — Frontmatter parser
  • renderMarkdown(markdown, options) / sanitizeUrl(url) / slugify(text) / parseLineRanges(raw) — Markdown rendering
  • highlightCode(code, lang) / highlightCodeLines(code, lang) — Build-time syntax highlighting
  • discoverDocs(docsDirAbs, options) — Document discovery and sidebar generation
  • buildSearchIndex(pages, options) / htmlToPlainText(html) — Search index builder
  • checkLinks(params) / createLinkResolver(params) — Internal link and anchor checker
  • normalizeI18nConfig(config) / normalizeVersionsConfig(config) / createBuildContexts(config) — i18n and versioning context helpers
  • buildSitemapXml(pages, config) / buildLlmsTxt(contextResults, config) / buildLlmsFullTxt(contextResults, config) — SEO and LLM outputs

Version Snapshot CLI#

bash
independoc version v1

Recursively copies the current docsDir into versioned_docs/<name>/ and prints an example JSON snippet to register the version in independoc.config.json. Existing snapshot directories and unsafe names (such as ../foo) are rejected without overwriting existing files.

Edit this pageLast updated:
Built with independoc itself — 0 npm dependencies.