|
1 | | -import { defineConfig } from 'vitepress' |
2 | | -import { fileURLToPath } from 'url' |
3 | | -import { resolve, dirname } from 'path' |
4 | | -import react from '@vitejs/plugin-react' |
5 | | -import { docsPlugin, buildSidebarFromDocs, ROOT } from '../../scripts/docs-plugin.js' |
6 | | - |
7 | | -const __filename = fileURLToPath(import.meta.url) |
8 | | -const __dirname = dirname(__filename) |
| 1 | +import { DefaultTheme, defineConfig } from 'vitepress'; |
| 2 | +import { resolve } from 'path'; |
| 3 | +import react from '@vitejs/plugin-react'; |
| 4 | +import { docsPlugin, buildSidebarFromDocs, ROOT } from '../../scripts/docs-plugin.js'; |
| 5 | +import packageJson from '../../package.json'; |
9 | 6 |
|
10 | 7 | // Sidebar is built dynamically from the .md files generated by docsPlugin() |
11 | 8 | // At first run docs/ may be empty — the plugin fills it during buildStart |
12 | 9 | const sidebar = buildSidebarFromDocs() |
13 | 10 |
|
| 11 | +const nav: DefaultTheme.NavItem[] = [ |
| 12 | + { text: 'Home', link: '/' }, |
| 13 | + { text: 'Hooks', link: '/hooks/state/createPubSubStore' }, |
| 14 | + { text: 'Components', link: '/components/ErrorBoundary' }, |
| 15 | + { text: 'Utils', link: '/utils/alphanumericCompare' }, |
| 16 | + { text: 'Types', link: '/types/' }, |
| 17 | + { text: 'npm', link: 'https://www.npmjs.com/package/@ndriadev/react-tools' } |
| 18 | +]; |
| 19 | + |
| 20 | +function buildNav(): DefaultTheme.NavItem[] { |
| 21 | + nav.push({ |
| 22 | + text: packageJson.version, |
| 23 | + items: [ |
| 24 | + { text: 'Changelog', link: 'https://github.com/nDriaDev/react-tools/blob/main/CHANGELOG.md' } |
| 25 | + ] |
| 26 | + }); |
| 27 | + return nav; |
| 28 | +} |
| 29 | + |
14 | 30 | export default defineConfig({ |
15 | 31 | title: 'React Tools', |
16 | 32 | description: 'A collection of Hooks, Components, Utilities and Types for React', |
@@ -38,14 +54,7 @@ export default defineConfig({ |
38 | 54 | themeConfig: { |
39 | 55 | logo: '/react-red.webp', |
40 | 56 |
|
41 | | - nav: [ |
42 | | - { text: 'Home', link: '/' }, |
43 | | - { text: 'Hooks', link: '/hooks/state/createPubSubStore' }, |
44 | | - { text: 'Components', link: '/components/ErrorBoundary' }, |
45 | | - { text: 'Utils', link: '/utils/alphanumericCompare' }, |
46 | | - { text: 'Types', link: '/types/' }, |
47 | | - { text: 'npm', link: 'https://www.npmjs.com/package/@ndriadev/react-tools' }, |
48 | | - ], |
| 57 | + nav: buildNav(), |
49 | 58 |
|
50 | 59 | sidebar, |
51 | 60 |
|
|
0 commit comments