1. Home
  2. ChevronRightPlugin API Reference
  3. ChevronRightPaths

Paths

PluginPathsAPI — safe workspace path resolution for Boltdocs plugins with directory traversal protection.

ctx.paths — PluginPathsAPILink

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 alsoLink

Last updated on July 27, 2026

Was this page helpful?