config.mts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. import { fileURLToPath, URL } from "node:url";
  2. import { defineConfig } from "vitepress";
  3. import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
  4. import Icons from "unplugin-icons/vite";
  5. // import Components from 'unplugin-vue-components/vite'
  6. import { FileSystemIconLoader } from "unplugin-icons/loaders";
  7. import {
  8. SVG,
  9. cleanupSVG,
  10. parseColors,
  11. runSVGO,
  12. deOptimisePaths,
  13. importDirectory,
  14. } from "@iconify/tools";
  15. import { compareColors, stringToColor } from "@iconify/utils/lib/colors";
  16. // https://vitepress.dev/reference/site-config
  17. export default defineConfig({
  18. title: "CocoBlockly帮助文档",
  19. description: "Cococlass help documents",
  20. srcDir: "pages",
  21. // themeConfig: {
  22. // search: {
  23. // provider: "local",
  24. // },
  25. // },
  26. appearance: false,
  27. vite: {
  28. publicDir: "../public",
  29. envDir: '../',
  30. // optimizeDeps: {
  31. // include: ["vue-i18n"],
  32. // },
  33. ssr: {
  34. // SSG Vue-i18n workaround
  35. noExternal: [/vue-i18n/],
  36. },
  37. plugins: [
  38. VueI18nPlugin({
  39. /* options */
  40. // locale messages resource pre-compile option
  41. // include: resolve(dirname(fileURLToPath(import.meta.url)), './path/to/src/locales/**'),
  42. }),
  43. Icons({
  44. compiler: "vue3",
  45. customCollections: {
  46. "ccrbi-plain": FileSystemIconLoader(
  47. "assets/icons/plain",
  48. async (svgStr) => {
  49. const svg = new SVG(svgStr);
  50. cleanupSVG(svg);
  51. parseColors(svg, {
  52. defaultColor: "currentColor",
  53. callback: (attr, colorStr, color) => {
  54. // console.log('Color:', colorStr, color);
  55. // 普通图标
  56. return "currentColor";
  57. // Change black to 'currentColor'
  58. // const blackColor = stringToColor("black");
  59. // if (color && compareColors(color, blackColor!)) {
  60. // return "currentColor";
  61. // }
  62. // switch (color?.type) {
  63. // case "none":
  64. // case "current":
  65. // return color;
  66. // }
  67. // throw new Error(
  68. // `Unexpected color "${colorStr}" in attribute ${attr}`
  69. // );
  70. },
  71. });
  72. // Optimise, but do not change shapes because they are animated
  73. runSVGO(svg, {
  74. keepShapes: true,
  75. });
  76. return svg.toMinifiedString({});
  77. }
  78. ),
  79. "ccrbi-colored": FileSystemIconLoader(
  80. "assets/icons/colored",
  81. async (svgStr) => {
  82. const svg = new SVG(svgStr);
  83. cleanupSVG(svg);
  84. // Optimise, but do not change shapes because they are animated
  85. runSVGO(svg, {
  86. keepShapes: true,
  87. });
  88. return svg.toMinifiedString({});
  89. }
  90. ),
  91. },
  92. }),
  93. ],
  94. resolve: {
  95. alias: [
  96. {
  97. find: /^.*\/VPNavBar\.vue$/,
  98. replacement: fileURLToPath(
  99. new URL("../components/CustomNavBar.vue", import.meta.url)
  100. ),
  101. },
  102. {
  103. find: "@/",
  104. replacement: fileURLToPath(new URL("../", import.meta.url)),
  105. },
  106. ],
  107. },
  108. },
  109. locales: {
  110. root: {
  111. label: "简体中文",
  112. lang: "zh-CN",
  113. themeConfig: {
  114. logo: "/logo.png",
  115. siteTitle: false,
  116. // https://vitepress.dev/reference/default-theme-config
  117. // nav: [
  118. // { text: 'Home', link: '/' },
  119. // { text: 'Examples', link: '/markdown-examples' }
  120. // ],
  121. sidebar: [
  122. { text: "关于CocoBlockly X", link: "/docs" },
  123. { text: "常见问题解答", link: "/docs/常见问题解答" },
  124. {
  125. text: "开始使用CocoBlockly X",
  126. link: "/docs/start-using-cocoblockly-x",
  127. },
  128. {
  129. text: "电子模块基本教学",
  130. collapsed: true,
  131. items: [{ text: "todo", link: "/docs" }],
  132. },
  133. ],
  134. // socialLinks: [
  135. // { icon: 'github', link: 'https://github.com/vuejs/vitepress' }
  136. // ]
  137. },
  138. },
  139. "zh-HK": {
  140. label: "繁体中文",
  141. lang: "zh-HK",
  142. themeConfig: {
  143. logo: "/logo.png",
  144. siteTitle: false,
  145. // https://vitepress.dev/reference/default-theme-config
  146. // nav: [
  147. // { text: 'Home', link: '/' },
  148. // { text: 'Examples', link: '/markdown-examples' }
  149. // ],
  150. sidebar: [
  151. { text: "什麽是CocoBlockly X", link: "/zh-HK/docs" },
  152. { text: "常見問題解答", link: "/zh-HK/docs/faq" },
  153. {
  154. text: "開始使用CocoBlockly X",
  155. link: "/zh-HK/docs/start-using-cocoblockly-x",
  156. },
  157. {
  158. text: "電子模組基本教學",
  159. collapsed: true,
  160. items: [{ text: "todo", link: "/zh-HK/docs" }],
  161. },
  162. ],
  163. // socialLinks: [
  164. // { icon: 'github', link: 'https://github.com/vuejs/vitepress' }
  165. // ]
  166. },
  167. },
  168. },
  169. });