Paths
PluginPathsAPI — safe workspace path resolution for Boltdocs plugins with directory traversal protection.
ctx.paths — PluginPathsAPI
Safe path-resolution helpers that validate every result stays inside
the workspace boundary. Both resolveDocs and resolveAsset reject
paths that escape the base directory (directory traversal) or attempt
to use an absolute path that lies outside the workspace.
// Resolve a path relative to the docs directory
const mdxFile = ctx.paths.resolveDocs('guides', 'getting-started', 'installation.mdx')
// Resolve a path relative to the project root (for assets, images, etc.)
const image = ctx.paths.resolveAsset('public', 'logo.webp')
// Build a file:// URL from an absolute workspace path
const fileUrl = ctx.paths.safeFileURL('/abs/path/to/diagram.svg')
// → 'file:///abs/path/to/diagram.svg'
These methods throw an Error when the resolved path falls outside
the workspace boundary:
// Throws: Path '../../etc/passwd' resolves to '/etc/passwd' which is
// outside the workspace boundary...
ctx.paths.resolveDocs('../../etc/passwd')
See also
- PluginContext — base context object
- Virtual Modules — runtime virtual module declarations
- Middleware — transform middleware pipeline
- Lifecycle Hooks — build/dev hooks, transform chains, and chain signals
Last updated on July 27, 2026