|
| 1 | +import type { DefaultTheme } from 'vitepress' |
| 2 | +import { fileURLToPath } from 'node:url' |
| 3 | +import { globSync } from 'tinyglobby' |
1 | 4 | import { defineConfig } from 'vitepress' |
2 | 5 | import { withMermaid } from 'vitepress-plugin-mermaid' |
3 | | -import devframeSidebar from './sidebar' |
| 6 | + |
| 7 | +const errorsDir = fileURLToPath(new URL('../errors/', import.meta.url)) |
| 8 | + |
| 9 | +function listErrorCodes(prefix: string): string[] { |
| 10 | + return globSync(`${prefix}*.md`, { cwd: errorsDir }) |
| 11 | + .map(f => f.replace(/\.md$/, '')) |
| 12 | + .sort() |
| 13 | +} |
| 14 | + |
| 15 | +function guideItems(prefix: string): DefaultTheme.NavItemWithLink[] { |
| 16 | + return [ |
| 17 | + { text: 'Introduction', link: `${prefix}/guide/` }, |
| 18 | + { text: 'Devtool Definition', link: `${prefix}/guide/devtool-definition` }, |
| 19 | + { text: 'Adapters', link: `${prefix}/guide/adapters` }, |
| 20 | + { text: 'RPC', link: `${prefix}/guide/rpc` }, |
| 21 | + { text: 'Shared State', link: `${prefix}/guide/shared-state` }, |
| 22 | + { text: 'Streaming', link: `${prefix}/guide/streaming` }, |
| 23 | + { text: 'Dock System', link: `${prefix}/guide/dock-system` }, |
| 24 | + { text: 'Commands', link: `${prefix}/guide/commands` }, |
| 25 | + { text: 'When Clauses', link: `${prefix}/guide/when-clauses` }, |
| 26 | + { text: 'Messages & Notifications', link: `${prefix}/guide/messages` }, |
| 27 | + { text: 'Structured Diagnostics', link: `${prefix}/guide/diagnostics` }, |
| 28 | + { text: 'Terminals', link: `${prefix}/guide/terminals` }, |
| 29 | + { text: 'Client', link: `${prefix}/guide/client` }, |
| 30 | + { text: 'Standalone CLI', link: `${prefix}/guide/standalone-cli` }, |
| 31 | + { text: 'Nuxt Helper', link: `${prefix}/guide/nuxt` }, |
| 32 | + { text: 'Agent-Native (experimental)', link: `${prefix}/guide/agent-native` }, |
| 33 | + ] |
| 34 | +} |
| 35 | + |
| 36 | +export function devframeSidebar(prefix = ''): DefaultTheme.SidebarItem[] { |
| 37 | + return [ |
| 38 | + { |
| 39 | + text: 'Guide', |
| 40 | + items: guideItems(prefix), |
| 41 | + }, |
| 42 | + { |
| 43 | + text: 'Error Reference', |
| 44 | + link: `${prefix}/errors/`, |
| 45 | + collapsed: true, |
| 46 | + items: listErrorCodes('DF').map(code => ({ |
| 47 | + text: code, |
| 48 | + link: `${prefix}/errors/${code}`, |
| 49 | + })), |
| 50 | + }, |
| 51 | + ] |
| 52 | +} |
| 53 | + |
| 54 | +export function devframeNav(prefix = ''): DefaultTheme.NavItemWithLink[] { |
| 55 | + return [ |
| 56 | + ...guideItems(prefix), |
| 57 | + { text: 'Error Reference', link: `${prefix}/errors/` }, |
| 58 | + ] |
| 59 | +} |
4 | 60 |
|
5 | 61 | export default withMermaid(defineConfig({ |
6 | 62 | title: 'DevFrame', |
7 | 63 | description: 'Framework-neutral foundation for building generic DevTools — RPC layer, hosts, and adapters.', |
8 | 64 | themeConfig: { |
9 | 65 | nav: [ |
10 | | - { text: 'Guide', link: '/guide/' }, |
11 | | - { text: 'Errors', link: '/errors/' }, |
| 66 | + { text: 'Guide', items: guideItems('') }, |
| 67 | + { text: 'Error Reference', link: '/errors/' }, |
12 | 68 | ], |
13 | 69 | sidebar: devframeSidebar(), |
14 | 70 | search: { |
|
0 commit comments