API Reference
Complete reference for Docmach configuration, tags, and programmatic usage.
Configuration
Configure Docmach in your package.json:
{
"docmach": {
"docs-directory": "docs",
"build-directory": "docmach",
"assets-folder": "assets",
"plugins": ["docmach:rss"]
}
}
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
docs-directory |
string | "." (root) |
Source directory containing Markdown files |
build-directory |
string | "./docmach" |
Output directory for generated HTML |
assets-folder |
string | "" (none) |
Directory with static assets to copy to output |
plugins |
array | [] |
Plugins to load: "docmach:name", file paths, or installed packages |
Plugins
Plugins extend the build through hooks, configured as an array of references:
"plugins": [
"docmach:rss",
{ "path": "./plugins/custom.js", "options": { "badge": "BETA" } }
]
| Hook | Runs | Receives |
|---|---|---|
preBuild |
Once, before files are discovered | { config } |
transformHtml |
Per page, before the file is written | Page context, return a string to replace the html |
page |
Per page, after the file is written | Page context |
postBuild |
Once, after the manifest and sitemap | { config, pages } |
Two plugins are bundled and referenced as docmach:rss and docmach:search-index. See the Plugins guide for the full hook and context reference.
Docmach Tag Syntax
Fragment Tag
Self-closing tag for HTML templates with variable substitution:
<docmach
type="fragment"
file="path/to/template.html"
params="key1: value1; key2: value2"
/>
Attributes:
type: Must be"fragment"file: Path to HTML template file (relative to project root)params: Semicolon-separated key-value pairs (optional)
Template syntax:
<div>
<h1>{{ key1 }}</h1>
<p>{{ key2 }}</p>
</div>
Function Tag
Self-closing tag for JavaScript-generated content:
<docmach
type="function"
file="path/to/function.js"
params="key1: value1; key2: value2"
/>
Attributes:
type: Must be"function"file: Path to JavaScript module (relative to project root)params: Parameters passed to function (optional)
Function signature:
export default function (params) {
// params = { key1: "value1", key2: "value2" }
return `<div>Generated HTML</div>`;
}
Wrapper Tag
Wrapping tag for composing layouts around Markdown content:
<docmach
type="wrapper"
file="path/to/layout.html"
replacement="placeholder"
params="key: value"
>
# Markdown content here This content will be rendered and inserted into {{
placeholder }}
</docmach>
Attributes:
type: Must be"wrapper"file: Path to HTML layout templatereplacement: Name of placeholder in template where content will be insertedparams: Parameters for template variables (optional)
Parameter Syntax
Simple Values
params="title: My Page; author: John Doe; count: 42"
Results in:
{ title: "My Page", author: "John Doe", count: 42 }
Nested Objects
params="user: {name: John, age: 30, email: john@example.com}"
Results in:
"plugins": [
"docmach:rss",
{ "path": "./plugins/custom.js", "options": { "badge": "BETA" } }
]
```0
### Mixed Parameters
```json
"plugins": [
"docmach:rss",
{ "path": "./plugins/custom.js", "options": { "badge": "BETA" } }
]
```1
Results in:
```json
"plugins": [
"docmach:rss",
{ "path": "./plugins/custom.js", "options": { "badge": "BETA" } }
]
```2
## CLI Commands
### Development Server
```json
"plugins": [
"docmach:rss",
{ "path": "./plugins/custom.js", "options": { "badge": "BETA" } }
]
```3
Starts development server with:
- Live reload via WebSocket
- File watching for auto-rebuild
- Serves on `http://localhost:4000` (or next available port)
### Production Build
```json
"plugins": [
"docmach:rss",
{ "path": "./plugins/custom.js", "options": { "badge": "BETA" } }
]
```4
Builds site for production:
- Compiles all Markdown files
- Copies assets
- Generates `docmach-manifest.json`
- Compiles Tailwind CSS
### Print Site Structure
```json
"plugins": [
"docmach:rss",
{ "path": "./plugins/custom.js", "options": { "badge": "BETA" } }
]
```5
Displays all pages in the build directory.
## Programmatic API
### Import and Use
```json
"plugins": [
"docmach:rss",
{ "path": "./plugins/custom.js", "options": { "badge": "BETA" } }
]
```6
### Use Cases
**Dynamic Blog Engine:**
```json
"plugins": [
"docmach:rss",
{ "path": "./plugins/custom.js", "options": { "badge": "BETA" } }
]
```7
**CMS Integration:**
```json
"plugins": [
"docmach:rss",
{ "path": "./plugins/custom.js", "options": { "badge": "BETA" } }
]
```8
## Build Manifest Schema
Generated at `{build-directory}/docmach-manifest.json`:
```json
"plugins": [
"docmach:rss",
{ "path": "./plugins/custom.js", "options": { "badge": "BETA" } }
]
```9
<!--DOCMACH_PLACEHOLDER_1-->
<!--DOCMACH_PLACEHOLDER_0-->