config.ts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. import { createRequire } from 'module'
  2. import { defineAdditionalConfig, type DefaultTheme } from 'vitepress'
  3. import { builtinModulesApiSidebarItems, extensionModulesApiSidebarItems } from '../sidebar'
  4. const require = createRequire(import.meta.url)
  5. const pkg = require('vitepress/package.json')
  6. export default defineAdditionalConfig({
  7. lang: 'zh-Hans',
  8. description: '一个基于Lua的轻量级跨平台自动构建工具',
  9. themeConfig: {
  10. nav: nav(),
  11. search: { options: searchOptions() },
  12. sidebar: {
  13. '/zh/guide/': { base: '/zh/guide/', items: guideSidebar() },
  14. '/zh/api/description/': { base: '/zh/api/description/', items: descriptionApiSidebar() },
  15. '/zh/api/scripts/': { base: '/zh/api/scripts/', items: scriptsApiSidebar() },
  16. '/zh/examples/': { base: '/zh/examples/', items: examplesSidebar() },
  17. },
  18. editLink: {
  19. pattern: 'https://github.com/xmake-io/xmake-docs/edit/master/docs/:path',
  20. text: '在 GitHub 上编辑此页面'
  21. },
  22. docFooter: {
  23. prev: '上一页',
  24. next: '下一页'
  25. },
  26. lastUpdated: {
  27. text: '最后更新于'
  28. },
  29. outline: {
  30. label: '页面导航'
  31. },
  32. notFound: {
  33. title: '页面未找到',
  34. quote:
  35. '但如果你不改变方向,并且继续寻找,你可能最终会到达你所前往的地方。',
  36. linkLabel: '前往首页',
  37. linkText: '带我回首页'
  38. },
  39. langMenuLabel: '多语言',
  40. returnToTopLabel: '回到顶部',
  41. sidebarMenuLabel: '菜单',
  42. darkModeSwitchLabel: '主题',
  43. lightModeSwitchTitle: '切换到浅色模式',
  44. darkModeSwitchTitle: '切换到深色模式',
  45. skipToContentLabel: '跳转到内容'
  46. }
  47. })
  48. function searchOptions(): Partial<DefaultTheme.AlgoliaSearchOptions> {
  49. return {
  50. placeholder: '搜索文档',
  51. translations: {
  52. button: {
  53. buttonText: '搜索文档',
  54. buttonAriaLabel: '搜索文档'
  55. },
  56. modal: {
  57. searchBox: {
  58. resetButtonTitle: '清除查询条件',
  59. resetButtonAriaLabel: '清除查询条件',
  60. cancelButtonText: '取消',
  61. cancelButtonAriaLabel: '取消'
  62. },
  63. startScreen: {
  64. recentSearchesTitle: '搜索历史',
  65. noRecentSearchesText: '没有搜索历史',
  66. saveRecentSearchButtonTitle: '保存至搜索历史',
  67. removeRecentSearchButtonTitle: '从搜索历史中移除',
  68. favoriteSearchesTitle: '收藏',
  69. removeFavoriteSearchButtonTitle: '从收藏中移除'
  70. },
  71. errorScreen: {
  72. titleText: '无法获取结果',
  73. helpText: '你可能需要检查你的网络连接'
  74. },
  75. footer: {
  76. selectText: '选择',
  77. navigateText: '切换',
  78. closeText: '关闭',
  79. searchByText: '搜索提供者'
  80. },
  81. noResultsScreen: {
  82. noResultsText: '无法找到相关结果',
  83. suggestedQueryText: '你可以尝试查询',
  84. reportMissingResultsText: '你认为该查询应该有结果?',
  85. reportMissingResultsLinkText: '点击反馈'
  86. }
  87. }
  88. }
  89. }
  90. }
  91. function nav(): DefaultTheme.NavItem[] {
  92. return [
  93. {
  94. text: '文档',
  95. activeMatch: `^/(guide|style-guide|cookbook|examples)/`,
  96. items: [
  97. { text: '使用指南', link: '/zh/guide/introduction', activeMatch: '/zh/guide/' },
  98. { text: '快速上手', link: '/zh/guide/quick-start' },
  99. { text: '示例', link: '/zh/examples/cpp/basic', activeMatch: '/zh/examples/' },
  100. { text: 'API 手册', link: '/zh/api/description/specification', activeMatch: '/zh/api/' }
  101. ]
  102. },
  103. {
  104. text: '生态系统',
  105. items: [
  106. {
  107. text: '资源',
  108. items: [
  109. { text: 'Xmake 包仓库', link: 'https://xmake.microblock.cc/' }
  110. ]
  111. },
  112. {
  113. text: '帮助',
  114. items: [
  115. { text: '社区', link: '/zh/about/contact' },
  116. { text: '问题反馈', link: 'https://github.com/xmake-io/xmake/issues' },
  117. { text: '谁在使用 Xmake?', link: '/zh/about/who_is_using_xmake' }
  118. ]
  119. },
  120. {
  121. text: '其他',
  122. items: [
  123. { text: '实验楼课程', link: '/zh/about/course' },
  124. { text: '周边物品', link: '/zh/about/peripheral_items' }
  125. ]
  126. }
  127. ]
  128. },
  129. { text: '赞助', link: '/zh/about/sponsor' }
  130. ]
  131. }
  132. function guideSidebar(): DefaultTheme.SidebarItem[] {
  133. return [
  134. {
  135. text: '开始',
  136. collapsed: false,
  137. items: [
  138. { text: '简介', link: 'introduction' },
  139. { text: '快速上手', link: 'quick-start' }
  140. ]
  141. },
  142. {
  143. text: '基础命令',
  144. collapsed: false,
  145. items: [
  146. { text: '创建工程', link: 'basic-commands/create-project' },
  147. { text: '编译配置', link: 'basic-commands/build-configuration' },
  148. { text: '构建目标', link: 'basic-commands/build-targets' },
  149. { text: '运行目标', link: 'basic-commands/run-targets' },
  150. { text: '交叉编译', link: 'basic-commands/cross-compilation' },
  151. { text: '切换工具链', link: 'basic-commands/switch-toolchains' },
  152. ]
  153. },
  154. {
  155. text: '工程配置',
  156. collapsed: false,
  157. items: [
  158. { text: '语法描述', link: 'project-configuration/syntax-description' },
  159. { text: '多级目录配置', link: 'project-configuration/multi-level-directories' },
  160. { text: '工具链配置', link: 'project-configuration/toolchain-configuration' },
  161. ]
  162. },
  163. {
  164. text: '包依赖管理',
  165. collapsed: false,
  166. items: [
  167. {
  168. text: '使用远程包',
  169. collapsed: true,
  170. items: [
  171. { text: '使用官方包', link: 'package-management/using-official-packages' },
  172. { text: '使用第三方包', link: 'package-management/using-third-party-packages' },
  173. { text: '在 CMake 中使用包', link: 'package-management/using-packages-in-cmake' },
  174. { text: '分发包到仓库', link: 'package-management/package-distribution' },
  175. ]
  176. },
  177. { text: '使用本地包', link: 'package-management/using-local-packages' },
  178. { text: '使用系统包', link: 'package-management/using-system-packages' },
  179. { text: '使用源码包', link: 'package-management/using-source-code-packages' },
  180. { text: '网络优化', link: 'package-management/network-optimization' },
  181. {
  182. text: 'CLI',
  183. collapsed: true,
  184. items: [
  185. { text: '工程内包管理', link: 'package-management/package-management-in-project' },
  186. { text: '仓库管理', link: 'package-management/repository-management' },
  187. { text: 'Xrepo CLI', link: 'package-management/xrepo-cli' },
  188. ]
  189. },
  190. ]
  191. },
  192. {
  193. text: '扩展',
  194. collapsed: false,
  195. items: [
  196. { text: '插件开发', link: 'extensions/plugin-development' },
  197. { text: '内置插件', link: 'extensions/builtin-plugins' },
  198. { text: 'IDE 集成插件', link: 'extensions/ide-integration-plugins' },
  199. { text: '主题风格', link: 'extensions/theme-style' },
  200. ]
  201. },
  202. {
  203. text: '最佳实践',
  204. collapsed: false,
  205. items: [
  206. { text: '常见问题', link: 'best-practices/faq' },
  207. { text: '性能优化', link: 'best-practices/performance' },
  208. ]
  209. },
  210. {
  211. text: '进阶主题',
  212. collapsed: false,
  213. items: [
  214. { text: '远程编译', link: 'extras/remote-compilation' },
  215. { text: '分布式编译', link: 'extras/distributed-compilation' },
  216. { text: '编译缓存加速', link: 'extras/build-cache' },
  217. { text: 'Unity 编译加速', link: 'extras/unity-build' },
  218. { text: '自动扫描源码', link: 'extras/autoscan-sourcecode' },
  219. { text: '尝试构建第三方源码', link: 'extras/trybuild-3rd-sourcecode' },
  220. { text: '环境变量', link: 'extras/environment-variables' },
  221. ]
  222. },
  223. {
  224. text: '下一步',
  225. collapsed: false,
  226. items: [
  227. { text: 'API 手册', link: '../api/description/specification' },
  228. { text: '示例', link: '../examples/cpp/basic' },
  229. ]
  230. }
  231. ]
  232. }
  233. function descriptionApiSidebar(): DefaultTheme.SidebarItem[] {
  234. return [
  235. {
  236. text: '描述域 API',
  237. collapsed: false,
  238. items: [
  239. { text: '接口规范', link: 'specification' },
  240. { text: '全局接口', link: 'global-interfaces' },
  241. { text: '条件判断', link: 'conditions' },
  242. { text: '辅助接口', link: 'helper-interfaces' },
  243. { text: '工程目标', link: 'project-target' },
  244. { text: '配置选项', link: 'configuration-option' },
  245. { text: '插件任务', link: 'plugin-and-task' },
  246. { text: '自定义规则', link: 'custom-rule' },
  247. { text: '自定义工具链', link: 'custom-toolchain' },
  248. { text: '包依赖', link: 'package-dependencies' },
  249. { text: '内置变量', link: 'builtin-variables' },
  250. { text: '内置规则', link: 'builtin-rules' },
  251. { text: '内置策略', link: 'builtin-policies' },
  252. { text: 'XPack 打包接口', link: 'xpack-interfaces' },
  253. { text: 'XPack 组件接口', link: 'xpack-component-interfaces' },
  254. ]
  255. },
  256. {
  257. text: '下一步',
  258. collapsed: false,
  259. items: [
  260. { text: '脚本域 API', link: '../scripts/target-instance' },
  261. { text: '使用指南', link: '../../guide/introduction' },
  262. { text: '示例', link: '../../examples/cpp/basic' },
  263. ]
  264. }
  265. ]
  266. }
  267. function scriptsApiSidebar(): DefaultTheme.SidebarItem[] {
  268. return [
  269. {
  270. text: '脚本域 API',
  271. collapsed: false,
  272. items: [
  273. { text: '目标实例', link: 'target-instance' },
  274. { text: '选项实例', link: 'option-instance' },
  275. { text: '包实例', link: 'package-instance' },
  276. ]
  277. },
  278. {
  279. text: '内置模块',
  280. collapsed: true,
  281. items: builtinModulesApiSidebarItems()
  282. },
  283. {
  284. text: '扩展模块',
  285. collapsed: false,
  286. items: extensionModulesApiSidebarItems()
  287. },
  288. { text: '原生模块', link: 'native-modules' },
  289. {
  290. text: '下一步',
  291. collapsed: false,
  292. items: [
  293. { text: '描述域 API', link: '../description/specification' },
  294. { text: '使用指南', link: '../../guide/introduction' },
  295. { text: '示例', link: '../../examples/cpp/basic' },
  296. ]
  297. }
  298. ]
  299. }
  300. function examplesSidebar(): DefaultTheme.SidebarItem[] {
  301. return [
  302. {
  303. text: 'C/C++',
  304. collapsed: false,
  305. items: [
  306. { text: '基础程序', link: 'cpp/basic' },
  307. { text: 'C++ 模块', link: 'cpp/cxx-modules' },
  308. { text: 'Wasm 程序', link: 'cpp/wasm' },
  309. { text: 'Qt 程序', link: 'cpp/qt' },
  310. { text: 'WDK 程序', link: 'cpp/wdk' },
  311. { text: 'WinSDK 程序', link: 'cpp/winsdk' },
  312. { text: 'MFC 程序', link: 'cpp/mfc' },
  313. { text: 'Protobuf 程序', link: 'cpp/protobuf' },
  314. { text: 'OpenMP 程序', link: 'cpp/openmp' },
  315. { text: 'Linux Bpf 程序', link: 'cpp/linux-bpf' },
  316. { text: 'Linux 内核驱动模块', link: 'cpp/linux-driver-module' },
  317. { text: 'ASN.1 程序', link: 'cpp/asn1' },
  318. { text: 'CppFront 程序', link: 'cpp/cppfront' },
  319. { text: 'Cosmocc 程序', link: 'cpp/cosmocc' },
  320. { text: '合并静态库', link: 'cpp/merge-static-libraries' },
  321. ]
  322. },
  323. {
  324. text: '语言绑定模块',
  325. collapsed: false,
  326. items: [
  327. { text: 'Swig 模块', link: 'bindings/swig' },
  328. { text: 'Lua 模块', link: 'bindings/lua-module' },
  329. { text: 'Python 模块', link: 'bindings/python-module' },
  330. { text: 'NodeJS 模块', link: 'bindings/nodejs-module' },
  331. ]
  332. },
  333. {
  334. text: '嵌入式程序',
  335. collapsed: false,
  336. items: [
  337. { text: 'Keil/MDK 程序', link: 'embed/keil-mdk' },
  338. { text: 'Keil/C51 程序', link: 'embed/keil-c51' },
  339. { text: 'Verilog 仿真程序', link: 'embed/verilog' },
  340. ]
  341. },
  342. {
  343. text: '其他语言',
  344. collapsed: false,
  345. items: [
  346. { text: 'ObjC 程序', link: 'other-languages/objc' },
  347. { text: 'Cuda 程序', link: 'other-languages/cuda' },
  348. { text: 'Lex/Yacc 程序', link: 'other-languages/lex-yacc' },
  349. { text: 'Fortran 程序', link: 'other-languages/fortran' },
  350. { text: 'Golang 程序', link: 'other-languages/golang' },
  351. { text: 'Dlang 程序', link: 'other-languages/dlang' },
  352. { text: 'Rust 程序', link: 'other-languages/rust' },
  353. { text: 'Swift 程序', link: 'other-languages/swift' },
  354. { text: 'Zig 程序', link: 'other-languages/zig' },
  355. { text: 'Vala 程序', link: 'other-languages/vala' },
  356. { text: 'Pascal 程序', link: 'other-languages/pascal' },
  357. { text: 'Nim 程序', link: 'other-languages/nim' },
  358. ]
  359. },
  360. {
  361. text: '下一步',
  362. collapsed: false,
  363. items: [
  364. { text: 'API 手册', link: '../api/description/specification' },
  365. { text: '使用指南', link: '../guide/introduction' },
  366. ]
  367. }
  368. ]
  369. }