|
| 1 | +import { defineConfig } from 'vitepress' |
| 2 | +import { withMermaid } from 'vitepress-plugin-mermaid' |
| 3 | +import llmstxt from 'vitepress-plugin-llms' |
| 4 | + |
| 5 | +const rawBase = process.env.VITEPRESS_BASE |
| 6 | +const base = rawBase |
| 7 | + ? rawBase.startsWith('/') |
| 8 | + ? rawBase.endsWith('/') ? rawBase : `${rawBase}/` |
| 9 | + : `/${rawBase}/` |
| 10 | + : '/' |
| 11 | + |
| 12 | +// Shared sidebar configuration |
| 13 | +const sharedSidebar = { |
| 14 | + '/en/': [ |
| 15 | + { |
| 16 | + text: 'Getting Started', |
| 17 | + items: [ |
| 18 | + { text: 'Introduction', link: '/en/' }, |
| 19 | + { text: 'Quick Start', link: '/en/guide/getting-started' }, |
| 20 | + { text: 'Architecture', link: '/en/guide/architecture' }, |
| 21 | + { text: 'Project Structure', link: '/en/guide/project-structure' }, |
| 22 | + ], |
| 23 | + }, |
| 24 | + { |
| 25 | + text: 'Algorithms', |
| 26 | + items: [ |
| 27 | + { text: 'Overview', link: '/en/guide/algorithms' }, |
| 28 | + { text: 'Huffman Coding', link: '/en/algorithms/huffman' }, |
| 29 | + { text: 'Arithmetic Coding', link: '/en/algorithms/arithmetic' }, |
| 30 | + { text: 'Range Coder', link: '/en/algorithms/range' }, |
| 31 | + { text: 'Run-Length Encoding', link: '/en/algorithms/rle' }, |
| 32 | + ], |
| 33 | + }, |
| 34 | + { |
| 35 | + text: 'API Reference', |
| 36 | + items: [ |
| 37 | + { text: 'Streaming API', link: '/en/api/streaming' }, |
| 38 | + { text: 'Go Library', link: '/en/api/go' }, |
| 39 | + { text: 'Rust Crate', link: '/en/api/rust' }, |
| 40 | + { text: 'C++ Header', link: '/en/api/cpp' }, |
| 41 | + ], |
| 42 | + }, |
| 43 | + { |
| 44 | + text: 'Benchmarks & Testing', |
| 45 | + items: [ |
| 46 | + { text: 'Performance Results', link: '/en/benchmarks/results' }, |
| 47 | + { text: 'How to Run', link: '/en/benchmarks/how-to-run' }, |
| 48 | + { text: 'Cross-Language Testing', link: '/en/testing/cross-language' }, |
| 49 | + ], |
| 50 | + }, |
| 51 | + { |
| 52 | + text: 'Reference', |
| 53 | + items: [ |
| 54 | + { text: 'OpenSpec Specs', link: 'https://github.com/LessUp/compress-kit/tree/master/openspec/specs' }, |
| 55 | + { text: 'Contributing', link: '/en/guide/contributing' }, |
| 56 | + { text: 'Changelog', link: '/en/release-notes/changelog' }, |
| 57 | + ], |
| 58 | + }, |
| 59 | + ], |
| 60 | + '/zh/': [ |
| 61 | + { |
| 62 | + text: '开始使用', |
| 63 | + items: [ |
| 64 | + { text: '项目介绍', link: '/zh/' }, |
| 65 | + { text: '快速开始', link: '/zh/guide/getting-started' }, |
| 66 | + { text: '架构设计', link: '/zh/guide/architecture' }, |
| 67 | + { text: '项目结构', link: '/zh/guide/project-structure' }, |
| 68 | + ], |
| 69 | + }, |
| 70 | + { |
| 71 | + text: '算法详解', |
| 72 | + items: [ |
| 73 | + { text: '算法综述', link: '/zh/guide/algorithms' }, |
| 74 | + { text: '霍夫曼编码', link: '/zh/algorithms/huffman' }, |
| 75 | + { text: '算术编码', link: '/zh/algorithms/arithmetic' }, |
| 76 | + { text: '区间编码', link: '/zh/algorithms/range' }, |
| 77 | + { text: '行程编码', link: '/zh/algorithms/rle' }, |
| 78 | + ], |
| 79 | + }, |
| 80 | + { |
| 81 | + text: 'API 参考', |
| 82 | + items: [ |
| 83 | + { text: 'Streaming API', link: '/zh/api/streaming' }, |
| 84 | + { text: 'Go 库', link: '/zh/api/go' }, |
| 85 | + { text: 'Rust 包', link: '/zh/api/rust' }, |
| 86 | + { text: 'C++ 头文件', link: '/zh/api/cpp' }, |
| 87 | + ], |
| 88 | + }, |
| 89 | + { |
| 90 | + text: '基准测试', |
| 91 | + items: [ |
| 92 | + { text: '性能结果', link: '/zh/benchmarks/results' }, |
| 93 | + { text: '如何运行', link: '/zh/benchmarks/how-to-run' }, |
| 94 | + { text: '跨语言测试', link: '/zh/testing/cross-language' }, |
| 95 | + ], |
| 96 | + }, |
| 97 | + { |
| 98 | + text: '参考', |
| 99 | + items: [ |
| 100 | + { text: 'OpenSpec 规范', link: 'https://github.com/LessUp/compress-kit/tree/master/openspec/specs' }, |
| 101 | + { text: '参与贡献', link: '/zh/guide/contributing' }, |
| 102 | + { text: '更新日志', link: '/zh/release-notes/changelog' }, |
| 103 | + ], |
| 104 | + }, |
| 105 | + ], |
| 106 | +} |
| 107 | + |
| 108 | +// Shared nav configuration |
| 109 | +const sharedNav = (lang: string) => [ |
| 110 | + { |
| 111 | + text: lang === 'zh' ? '首页' : 'Home', |
| 112 | + link: lang === 'zh' ? '/zh/' : '/en/', |
| 113 | + activeMatch: lang === 'zh' ? '^/zh/$' : '^/en/$' |
| 114 | + }, |
| 115 | + { |
| 116 | + text: lang === 'zh' ? '开始' : 'Get Started', |
| 117 | + link: lang === 'zh' ? '/zh/guide/getting-started' : '/en/guide/getting-started', |
| 118 | + activeMatch: lang === 'zh' ? '/zh/guide/' : '/en/guide/' |
| 119 | + }, |
| 120 | + { |
| 121 | + text: lang === 'zh' ? '算法' : 'Algorithms', |
| 122 | + link: lang === 'zh' ? '/zh/guide/algorithms' : '/en/guide/algorithms', |
| 123 | + activeMatch: lang === 'zh' ? '/zh/algorithms/' : '/en/algorithms/' |
| 124 | + }, |
| 125 | + { |
| 126 | + text: 'API', |
| 127 | + link: lang === 'zh' ? '/zh/api/go' : '/en/api/go', |
| 128 | + activeMatch: lang === 'zh' ? '/zh/api/' : '/en/api/' |
| 129 | + }, |
| 130 | + { |
| 131 | + text: lang === 'zh' ? '基准' : 'Benchmarks', |
| 132 | + link: lang === 'zh' ? '/zh/benchmarks/results' : '/en/benchmarks/results', |
| 133 | + activeMatch: lang === 'zh' ? '/zh/benchmarks/' : '/en/benchmarks/' |
| 134 | + }, |
| 135 | +] |
| 136 | + |
| 137 | +export default withMermaid(defineConfig({ |
| 138 | + base, |
| 139 | + title: 'CompressKit', |
| 140 | + titleTemplate: ':title | CompressKit', |
| 141 | + description: 'Classic lossless compression algorithms in C++17, Go, and Rust with cross-language binary verification.', |
| 142 | + cleanUrls: true, |
| 143 | + lastUpdated: true, |
| 144 | + appearance: true, |
| 145 | + |
| 146 | + sitemap: { |
| 147 | + hostname: 'https://lessup.github.io/compress-kit/', |
| 148 | + }, |
| 149 | + |
| 150 | + locales: { |
| 151 | + root: { |
| 152 | + label: 'English', |
| 153 | + lang: 'en-US', |
| 154 | + themeConfig: { |
| 155 | + nav: sharedNav('en'), |
| 156 | + sidebar: sharedSidebar['/en/'], |
| 157 | + editLink: { |
| 158 | + pattern: 'https://github.com/LessUp/compress-kit/edit/master/docs/:path', |
| 159 | + text: 'Edit this page on GitHub', |
| 160 | + }, |
| 161 | + footer: false, |
| 162 | + outline: { |
| 163 | + level: [2, 3], |
| 164 | + label: 'On this page', |
| 165 | + }, |
| 166 | + lastUpdated: { |
| 167 | + text: 'Last updated', |
| 168 | + }, |
| 169 | + docFooter: { |
| 170 | + prev: 'Previous page', |
| 171 | + next: 'Next page', |
| 172 | + }, |
| 173 | + returnToTopLabel: 'Return to top', |
| 174 | + sidebarMenuLabel: 'Menu', |
| 175 | + darkModeSwitchLabel: 'Theme', |
| 176 | + search: { |
| 177 | + provider: 'local', |
| 178 | + options: { |
| 179 | + translations: { |
| 180 | + button: { |
| 181 | + buttonText: 'Search', |
| 182 | + buttonAriaLabel: 'Search documentation', |
| 183 | + }, |
| 184 | + modal: { |
| 185 | + noResultsText: 'No results found', |
| 186 | + resetButtonTitle: 'Clear search', |
| 187 | + footer: { |
| 188 | + selectText: 'to select', |
| 189 | + navigateText: 'to navigate', |
| 190 | + closeText: 'to close', |
| 191 | + }, |
| 192 | + }, |
| 193 | + }, |
| 194 | + }, |
| 195 | + }, |
| 196 | + }, |
| 197 | + }, |
| 198 | + zh: { |
| 199 | + label: '简体中文', |
| 200 | + lang: 'zh-CN', |
| 201 | + link: '/zh/', |
| 202 | + themeConfig: { |
| 203 | + nav: sharedNav('zh'), |
| 204 | + sidebar: sharedSidebar['/zh/'], |
| 205 | + editLink: { |
| 206 | + pattern: 'https://github.com/LessUp/compress-kit/edit/master/docs/:path', |
| 207 | + text: '在 GitHub 上编辑此页', |
| 208 | + }, |
| 209 | + footer: false, |
| 210 | + outline: { |
| 211 | + level: [2, 3], |
| 212 | + label: '本页内容', |
| 213 | + }, |
| 214 | + lastUpdated: { |
| 215 | + text: '最后更新', |
| 216 | + }, |
| 217 | + docFooter: { |
| 218 | + prev: '上一页', |
| 219 | + next: '下一页', |
| 220 | + }, |
| 221 | + returnToTopLabel: '返回顶部', |
| 222 | + sidebarMenuLabel: '菜单', |
| 223 | + darkModeSwitchLabel: '主题', |
| 224 | + search: { |
| 225 | + provider: 'local', |
| 226 | + options: { |
| 227 | + translations: { |
| 228 | + button: { |
| 229 | + buttonText: '搜索文档', |
| 230 | + buttonAriaLabel: '搜索文档', |
| 231 | + }, |
| 232 | + modal: { |
| 233 | + noResultsText: '无法找到相关结果', |
| 234 | + resetButtonTitle: '清除查询条件', |
| 235 | + footer: { |
| 236 | + selectText: '选择', |
| 237 | + navigateText: '切换', |
| 238 | + closeText: '关闭', |
| 239 | + }, |
| 240 | + }, |
| 241 | + }, |
| 242 | + }, |
| 243 | + }, |
| 244 | + }, |
| 245 | + }, |
| 246 | + }, |
| 247 | + |
| 248 | + themeConfig: { |
| 249 | + outline: [2, 3], |
| 250 | + search: { provider: 'local' }, |
| 251 | + socialLinks: [ |
| 252 | + { icon: 'github', link: 'https://github.com/LessUp/compress-kit' }, |
| 253 | + ], |
| 254 | + logo: { |
| 255 | + light: '/logo.svg', |
| 256 | + dark: '/logo-dark.svg', |
| 257 | + alt: 'CompressKit Logo' |
| 258 | + }, |
| 259 | + siteTitle: 'CompressKit', |
| 260 | + externalLinkIcon: true, |
| 261 | + }, |
| 262 | + |
| 263 | + markdown: { |
| 264 | + lineNumbers: true, |
| 265 | + languageAlias: { |
| 266 | + cuda: 'cpp', |
| 267 | + }, |
| 268 | + }, |
| 269 | + |
| 270 | + head: [ |
| 271 | + ['link', { rel: 'canonical', href: 'https://lessup.github.io/compress-kit/' }], |
| 272 | + ['meta', { charset: 'UTF-8' }], |
| 273 | + ['meta', { name: 'viewport', content: 'width=device-width, initial-scale=1.0' }], |
| 274 | + ['meta', { name: 'theme-color', content: '#2563eb', media: '(prefers-color-scheme: light)' }], |
| 275 | + ['meta', { name: 'theme-color', content: '#0f172a', media: '(prefers-color-scheme: dark)' }], |
| 276 | + ['meta', { name: 'keywords', content: 'compression algorithms, huffman coding, arithmetic coding, range coder, run-length encoding, C++, Go, Rust, lossless compression, cross-language conformance' }], |
| 277 | + ['meta', { name: 'author', content: 'CompressKit Team' }], |
| 278 | + ['meta', { name: 'robots', content: 'index, follow' }], |
| 279 | + ['meta', { property: 'og:type', content: 'website' }], |
| 280 | + ['meta', { property: 'og:locale', content: 'en_US' }], |
| 281 | + ['meta', { property: 'og:title', content: 'CompressKit | Compression Algorithms Collection' }], |
| 282 | + ['meta', { property: 'og:description', content: 'Classic lossless compression algorithms in C++17, Go, and Rust with cross-language binary verification.' }], |
| 283 | + ['meta', { property: 'og:url', content: 'https://lessup.github.io/compress-kit/' }], |
| 284 | + ['meta', { property: 'og:site_name', content: 'CompressKit' }], |
| 285 | + ['meta', { property: 'og:image', content: '/compress-kit/og-image.svg' }], |
| 286 | + ['link', { rel: 'icon', type: 'image/svg+xml', href: '/compress-kit/logo.svg' }], |
| 287 | + ], |
| 288 | + |
| 289 | + vite: { |
| 290 | + plugins: [llmstxt()], |
| 291 | + resolve: { |
| 292 | + alias: { |
| 293 | + '@theme': '/.vitepress/theme', |
| 294 | + }, |
| 295 | + }, |
| 296 | + }, |
| 297 | +})) |
0 commit comments