|
| 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) |
| 9 | + |
| 10 | +// Sidebar is built dynamically from the .md files generated by docsPlugin() |
| 11 | +// At first run docs/ may be empty — the plugin fills it during buildStart |
| 12 | +const sidebar = buildSidebarFromDocs() |
| 13 | + |
| 14 | +export default defineConfig({ |
| 15 | + title: 'React Tools', |
| 16 | + description: 'A collection of Hooks, Components, Utilities and Types for React', |
| 17 | + lang: 'en-US', |
| 18 | + |
| 19 | + head: [ |
| 20 | + ['link', { rel: 'icon', href: '/react-red.webp' }], |
| 21 | + ['meta', { name: 'theme-color', content: '#f53340' }], |
| 22 | + ['meta', { property: 'og:type', content: 'website' }], |
| 23 | + ['meta', { property: 'og:title', content: 'React Tools' }], |
| 24 | + ['meta', { property: 'og:description', content: 'Hooks, Components, Utilities and Types for React' }], |
| 25 | + ['meta', { property: 'og:image', content: '/react-red.webp' }], |
| 26 | + ['link', { rel: 'sitemap', type: 'application/xml', href: '/sitemap.xml' }], |
| 27 | + ], |
| 28 | + |
| 29 | + base: '/', |
| 30 | + cleanUrls: true, |
| 31 | + |
| 32 | + // VitePress built-in sitemap (generates /sitemap.xml during build) |
| 33 | + // We also generate one manually with our plugin for full control, but |
| 34 | + // enabling this adds <lastmod> and <changefreq> awareness from VitePress itself. |
| 35 | + // Disable to avoid duplicate – our plugin handles it with richer data. |
| 36 | + // sitemap: { hostname: 'https://react-tools.ndria.dev' }, |
| 37 | + |
| 38 | + themeConfig: { |
| 39 | + logo: '/react-red.webp', |
| 40 | + |
| 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 | + ], |
| 49 | + |
| 50 | + sidebar, |
| 51 | + |
| 52 | + socialLinks: [ |
| 53 | + { icon: 'github', link: 'https://github.com/nDriaDev/react-tools' }, |
| 54 | + ], |
| 55 | + |
| 56 | + footer: { |
| 57 | + message: 'Released under the MIT License.', |
| 58 | + copyright: 'Copyright © 2024-present nDriaDev', |
| 59 | + }, |
| 60 | + |
| 61 | + search: { provider: 'local' } |
| 62 | + }, |
| 63 | + |
| 64 | + vite: { |
| 65 | + plugins: [ |
| 66 | + react(), |
| 67 | + docsPlugin() as any, |
| 68 | + ], |
| 69 | + resolve: { |
| 70 | + alias: [ |
| 71 | + // Library root alias (demo files import from '../../...' which resolves to src/) |
| 72 | + { |
| 73 | + find: '@ndriadev/react-tools', |
| 74 | + replacement: resolve(ROOT, 'src/index.ts'), |
| 75 | + }, |
| 76 | + // assets/ is now inside src/assets – relative '../../../../assets/...' from |
| 77 | + // src/demo/hooks/category/tool/ resolves correctly to src/assets/ |
| 78 | + // No alias needed; the path arithmetic already points to src/assets/ |
| 79 | + ], |
| 80 | + }, |
| 81 | + optimizeDeps: { |
| 82 | + include: ['react', 'react-dom', 'react-dom/client'], |
| 83 | + }, |
| 84 | + assetsInclude: ['**/*.mp3', '**/*.mp4'], |
| 85 | + build: { |
| 86 | + minify: true |
| 87 | + } |
| 88 | + }, |
| 89 | + |
| 90 | + markdown: { |
| 91 | + lineNumbers: true, |
| 92 | + theme: { light: 'github-light', dark: 'github-dark' }, |
| 93 | + } |
| 94 | +}) |
0 commit comments