config.mts
1 import { withSidebar } from 'vitepress-sidebar' 2 import pkg from '../../../package.json' with { type: 'json' } 3 import { defineConfig, UserConfig } from 'vitepress' 4 import { withI18n } from 'vitepress-i18n' 5 import type { VitePressSidebarOptions } from 'vitepress-sidebar/types' 6 import type { VitePressI18nOptions } from 'vitepress-i18n/types' 7 8 const { name, repository, homepage } = pkg 9 const capitalizeFirst = (str: string): string => str.charAt(0).toUpperCase() + str.slice(1) 10 const supportLocales = ['en', 'zhHans'] 11 const defaultLocale: string = supportLocales[0] 12 13 const vitePressI18nConfigs: VitePressI18nOptions = { 14 locales: supportLocales, 15 rootLocale: defaultLocale, 16 searchProvider: 'local', 17 description: { 18 en: 'TUUI is a free and open-source desktop application designed for AI agentic systems, leveraging the Model Context Protocol.', 19 zhHans: 20 'TUUI 是一款基于模型上下文协议(Model Context Protocol)、专为AI智能体系统设计的免费开源桌面应用程序。' 21 }, 22 themeConfig: { 23 en: { 24 nav: [ 25 { 26 text: 'Getting Started', 27 link: '/installation-and-build/getting-started' 28 } 29 ] 30 }, 31 zhHans: { 32 nav: [ 33 { 34 text: '入门', 35 link: '/zhHans/installation-and-build/getting-started' 36 } 37 ] 38 } 39 } 40 } 41 42 const vitePressSidebarConfigs: VitePressSidebarOptions[] = [ 43 ...supportLocales.map((lang) => { 44 return { 45 collapsed: false, 46 useTitleFromFileHeading: true, 47 useTitleFromFrontmatter: true, 48 useFolderTitleFromIndexFile: true, 49 sortMenusByFrontmatterOrder: true, 50 hyphenToSpace: true, 51 capitalizeEachWords: true, 52 manualSortFileNameByPriority: [ 53 'introduction.md', 54 'installation-and-build', 55 'project-structures', 56 'electron-how-to' 57 ], 58 documentRootPath: `/src/${lang}`, 59 resolvePath: defaultLocale === lang ? '/' : `/${lang}/`, 60 ...(defaultLocale === lang ? {} : { basePath: `/${lang}/` }) 61 } 62 }) 63 ] 64 65 const vitePressConfigs: UserConfig = { 66 title: capitalizeFirst(name), 67 lastUpdated: true, 68 outDir: '../dist', 69 head: [ 70 ['link', { rel: 'icon', href: '/logo.png' }], 71 ['link', { rel: 'shortcut icon', href: '/favicon.ico' }], 72 [ 73 'meta', 74 { 75 name: 'keywords', 76 content: 77 'MCP, Model Context Protocol, Client, TUUI, AI, agent, LLM, 模型上下文协议, 桌面应用, 开源工具, AI代理, 开发者工具, AI开发, 工具调用' 78 } 79 ] 80 ], 81 cleanUrls: true, 82 metaChunk: true, 83 rewrites: { 84 'en/:rest*': ':rest*' 85 }, 86 sitemap: { 87 hostname: homepage 88 }, 89 themeConfig: { 90 logo: { src: '/icon.png', width: 24, height: 24 }, 91 editLink: { 92 pattern: 'https://github.com/AI-QL/tuui/edit/main/docs/src/:path' 93 }, 94 socialLinks: [{ icon: 'github', link: repository.url.replace('.git', '') }] 95 } 96 } 97 98 export default defineConfig( 99 withSidebar(withI18n(vitePressConfigs, vitePressI18nConfigs), vitePressSidebarConfigs) 100 )