Simplified Config API
Requirement: withOpenSpec wraps a VitePress config
The system SHALL provide a withOpenSpec(config, options?) function that accepts a VitePress UserConfig object, calls generateOpenSpecPages() synchronously, and returns the config with the openspec Vite plugin, nav entry, and sidebar section merged in.
Zero-argument usage uses defaults
- WHEN
withOpenSpec({})is called with no options - THEN it resolves
specDirto'./openspec'andsrcDirtoprocess.cwd(), runs page generation, and returns the config augmented with the Vite plugin
Nav entry is prepended by default
- WHEN
withOpenSpec({ themeConfig: { nav: [] } })is called - THEN the returned config's
themeConfig.navarray contains the openspec nav item as its first element
Sidebar section is injected by default
- WHEN
withOpenSpec({ themeConfig: { sidebar: {} } })is called - THEN the returned config's
themeConfig.sidebarcontains a key'/openspec/'with the generated sidebar items
Nav injection can be disabled
- WHEN
withOpenSpec(config, { nav: false })is called - THEN the returned config's
themeConfig.navis not modified by the plugin
Sidebar injection can be disabled
- WHEN
withOpenSpec(config, { sidebar: false })is called - THEN the returned config's
themeConfig.sidebaris not modified by the plugin
Vite plugin is always merged
- WHEN
withOpenSpecis called with any options - THEN the returned config's
vite.pluginsarray contains the openspec Vite plugin
Existing Vite plugins are preserved
- WHEN
withOpenSpec({ vite: { plugins: [myPlugin] } })is called - THEN the returned config's
vite.pluginsarray contains bothmyPluginand the openspec plugin
outDir option controls sidebar key and nav link
- WHEN
withOpenSpec(config, { outDir: 'project-docs' })is called - THEN the sidebar key is
'/project-docs/'and the nav link points to/project-docs/
Requirement: withOpenSpec is exported from the package root
The system SHALL export withOpenSpec from vitepress-plugin-openspec so it can be imported alongside existing exports.
Named import works
- WHEN a user writes
import { withOpenSpec } from 'vitepress-plugin-openspec' - THEN the import resolves to the
withOpenSpecfunction without errors