import { fileURLToPath, URL } from "node:url"; import { defineConfig } from "vitepress"; import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite"; import Icons from "unplugin-icons/vite"; // import Components from 'unplugin-vue-components/vite' import { FileSystemIconLoader } from "unplugin-icons/loaders"; import { SVG, cleanupSVG, parseColors, runSVGO, deOptimisePaths, importDirectory, } from "@iconify/tools"; import { compareColors, stringToColor } from "@iconify/utils/lib/colors"; // https://vitepress.dev/reference/site-config export default defineConfig({ title: "CocoBlockly帮助文档", description: "Cococlass help documents", srcDir: "pages", // themeConfig: { // search: { // provider: "local", // }, // }, vite: { publicDir: "../public", plugins: [ VueI18nPlugin({ /* options */ // locale messages resource pre-compile option // include: resolve(dirname(fileURLToPath(import.meta.url)), './path/to/src/locales/**'), }), Icons({ compiler: "vue3", customCollections: { "ccrbi-plain": FileSystemIconLoader( "assets/icons/plain", async (svgStr) => { const svg = new SVG(svgStr); cleanupSVG(svg); parseColors(svg, { defaultColor: "currentColor", callback: (attr, colorStr, color) => { // console.log('Color:', colorStr, color); // 普通图标 return "currentColor"; // Change black to 'currentColor' // const blackColor = stringToColor("black"); // if (color && compareColors(color, blackColor!)) { // return "currentColor"; // } // switch (color?.type) { // case "none": // case "current": // return color; // } // throw new Error( // `Unexpected color "${colorStr}" in attribute ${attr}` // ); }, }); // Optimise, but do not change shapes because they are animated runSVGO(svg, { keepShapes: true, }); return svg.toMinifiedString({}); } ), "ccrbi-colored": FileSystemIconLoader( "assets/icons/colored", async (svgStr) => { const svg = new SVG(svgStr); cleanupSVG(svg); // Optimise, but do not change shapes because they are animated runSVGO(svg, { keepShapes: true, }); return svg.toMinifiedString({}); } ), }, }), ], resolve: { alias: [ { find: /^.*\/VPNavBar\.vue$/, replacement: fileURLToPath( new URL("../components/CustomNavBar.vue", import.meta.url) ), }, { find: "@/", replacement: fileURLToPath(new URL("../", import.meta.url)), }, ], }, }, locales: { root: { label: "简体中文", lang: "zh-CN", themeConfig: { logo: "/logo.png", siteTitle: false, // https://vitepress.dev/reference/default-theme-config // nav: [ // { text: 'Home', link: '/' }, // { text: 'Examples', link: '/markdown-examples' } // ], sidebar: [ { text: "关于CocoBlockly X", link: "/docs" }, { text: "常见问题解答", link: "/docs/faq" }, { text: "开始使用CocoBlockly X", link: "/docs/start-using-cocoblockly-x", }, { text: "电子模块基本教学", collapsed: true, items: [{ text: "todo", link: "/docs" }], }, ], // socialLinks: [ // { icon: 'github', link: 'https://github.com/vuejs/vitepress' } // ] }, }, "zh-HK": { label: "繁体中文", lang: "zh-HK", themeConfig: { logo: "/logo.png", siteTitle: false, // https://vitepress.dev/reference/default-theme-config // nav: [ // { text: 'Home', link: '/' }, // { text: 'Examples', link: '/markdown-examples' } // ], sidebar: [ { text: "什麽是CocoBlockly X", link: "/zh-HK/docs" }, { text: "常見問題解答", link: "/zh-HK/docs/faq" }, { text: "開始使用CocoBlockly X", link: "/zh-HK/docs/start-using-cocoblockly-x", }, { text: "電子模組基本教學", collapsed: true, items: [{ text: "todo", link: "/zh-HK/docs" }], }, ], // socialLinks: [ // { icon: 'github', link: 'https://github.com/vuejs/vitepress' } // ] }, }, }, });