Markdown & Web Components#
independoc supports CommonMark core syntax, GFM extensions, Docusaurus-style Admonitions, and standard browser Web Components (Custom Elements) directly inside Markdown.
Admonitions (Callouts)#
::: directives are rendered to static <aside> HTML at build time with zero client JavaScript.
Tabs (<nd-tabs>)#
Standard Markdown (code blocks, lists, links) can be nested directly inside <nd-tabs> and <nd-tab>. Adding group-id synchronizes tab selection across instances and pages via localStorage.
import { buildSite } from 'independoc';
const result = await buildSite({
cwd: process.cwd(),
overrides: { onBrokenLinks: 'error' },
});
console.log(`Built ${result.pageCount} pages in ${result.durationMs}ms`);{
"title": "Team Docs",
"docsDir": "docs",
"outDir": "dist",
"lang": "en",
"onBrokenLinks": "error"
}node ./bin/independoc.js check
node ./bin/independoc.js build --base /team-docs/Callouts, Badges, and Collapsible Details#
- Inline badges:
Zero Dep Stable Experimental Breaking - Component-style callout:
The built-in components.js bundle is only included on pages that actually contain <nd-*> elements. Plain Markdown pages ship zero component script.
- Collapsible details (
<nd-details>or native<details>):
Expands into a native HTML <details> element for accessible keyboard and screen-reader interaction. Nested <nd-tabs> keep their group sync intact.
Syntax Highlighting & Code Block Line Decorations#
Fenced code blocks (```lang title="filename") are highlighted at build time with zero client-side syntax-highlighting JS.
Supported languages: js / ts / json / bash / html / css / go / rust / python / yaml / markdown / diff / diff-<lang>
{1,3-5}: Highlight 1-based line numbers or rangesshowLineNumbers/showLineNumbers=10: Render CSS-based line numbers (excluded from copy)// [!code highlight]/// [!code ++]/// [!code --]: Line-end markers for highlight, addition, or deletion (stripped from rendered output)diff/diff-<lang>: Highlight leading+,-, and@@lines (deleted lines are skipped when copying)
Live Example: Line Numbers, Line Highlights, and Add/Remove Markers#
export function greet(name) {
const oldPrefix = 'Hi';
const prefix = 'Hello';
return `${prefix}, ${name}!`;
}Live Example: diff Code Block#
"lang": "en",
- "onBrokenLinks": "warn"
+ "onBrokenLinks": "error",
+ "showLastUpdated": trueCard Grids (<nd-card-grid> / <nd-card>)#
Responsive cards for landing pages and feature overviews. href resolves relative Markdown paths at build time and strips dangerous schemes such as javascript:. Set cols to 2, 3, or 4, or omit for auto-fit.
Launch a zero-dependency documentation site in minutes.
Full reference for independoc.config.json and Frontmatter.
Step Lists (<nd-steps>)#
Renders an ordered list as a numbered step-by-step timeline using pure CSS (no client JS required).
Clone the repository.
bashgit clone https://github.com/stakme/independoc.gitStart the preview server.
bashnpm run serve
File Trees (<nd-file-tree>)#
Renders nested Markdown lists as a monospace directory tree while remaining readable as standard lists without JS.
docs/
- index.md Homepage
guides/
_category.json- 01-zero-dependency-design.md
- independoc.config.json
GFM Tables & Task Lists#
| Capability | External npm Packages | Browser JS |
|---|---|---|
| Markdown → HTML | 0 | None |
| Syntax highlighting & line decorations | 0 | None (build-time) |
| Mobile drawer & language/version switchers | 0 | None (HTML/CSS) |
| Tabs, search, theme toggle, ToC scroll spy | 0 | Minimal vanilla JS |
- Build, preview, and test using only Node.js standard APIs
- Automatic blocking of dangerous URL schemes (
javascript:,vbscript:,data:text/html) - Unicode heading slugs and CJK 2-gram local full-text search
To add your own interactive components, see Custom Web Components Guide.