|
| 1 | +import { defineConfig, loadEnv } from "vitepress"; |
| 2 | +import { generateSidebar } from "vitepress-sidebar"; |
| 3 | +import { VitePWA } from "vite-plugin-pwa"; |
| 4 | +import { pwaConfig } from "./pwa.config"; |
| 5 | + |
| 6 | +// 使用 VitePress 的 loadEnv 加载环境变量 |
| 7 | +// mode: '' 会加载 .env 文件(只加载 VITE_ 开头的变量) |
| 8 | +const env = loadEnv("", process.cwd()); |
| 9 | + |
| 10 | +export default defineConfig({ |
| 11 | + srcDir: "./src", |
| 12 | + base: env.VITE_BASE_URL || "/", |
| 13 | + lastUpdated: true, |
| 14 | + head: [ |
| 15 | + ["link", { rel: "icon", href: "/favicon.svg", type: "image/svg+xml" }], |
| 16 | + ], |
| 17 | + title: "GFL", |
| 18 | + description: "A powerful command-line tool that simplifies GitHub Flow workflows", |
| 19 | + outDir: "./dist", |
| 20 | + vite: { |
| 21 | + plugins: [VitePWA(pwaConfig)], |
| 22 | + }, |
| 23 | + locales: { |
| 24 | + root: { |
| 25 | + label: "简体中文", |
| 26 | + lang: "zh-CN", |
| 27 | + title: "SITE_TITLE", |
| 28 | + description: "SITE_DESCRIPTION", |
| 29 | + themeConfig: { |
| 30 | + logo: "/favicon.svg", |
| 31 | + lastUpdated: { |
| 32 | + text: "更新时间", |
| 33 | + }, |
| 34 | + docFooter: { |
| 35 | + prev: "上一页", |
| 36 | + next: "下一页", |
| 37 | + }, |
| 38 | + outline: { |
| 39 | + label: "大纲", |
| 40 | + level: [2, 3], |
| 41 | + }, |
| 42 | + nav: [ |
| 43 | + { text: "首页", link: "/" }, |
| 44 | + { text: "组件", link: "/posts/components/index.md" }, |
| 45 | + { text: "Utils", link: "/posts/utils/index.md" }, |
| 46 | + { text: "规范", link: "/posts/standard/index.md" }, |
| 47 | + { text: "事故", link: "/posts/incidents/index.md" }, |
| 48 | + ], |
| 49 | + sidebar: generateSidebar({ |
| 50 | + documentRootPath: "src", |
| 51 | + scanStartPath: "/posts", |
| 52 | + collapsed: false, |
| 53 | + capitalizeFirst: true, |
| 54 | + useTitleFromFileHeading: true, |
| 55 | + useTitleFromFrontmatter: true, |
| 56 | + hyphenToSpace: true, |
| 57 | + excludePattern: ["README.md"], |
| 58 | + debugPrint: false, |
| 59 | + }), |
| 60 | + search: { |
| 61 | + provider: "local", |
| 62 | + options: { |
| 63 | + translations: { |
| 64 | + button: { |
| 65 | + buttonText: "搜索", |
| 66 | + buttonAriaLabel: "搜索文档", |
| 67 | + }, |
| 68 | + modal: { |
| 69 | + noResultsText: "无法找到相关结果", |
| 70 | + resetButtonTitle: "清除查询条件", |
| 71 | + footer: { |
| 72 | + selectText: "选择", |
| 73 | + navigateText: "切换", |
| 74 | + closeText: "关闭", |
| 75 | + }, |
| 76 | + }, |
| 77 | + }, |
| 78 | + }, |
| 79 | + }, |
| 80 | + socialLinks: [ |
| 81 | + { icon: "github", link: "https://github.com/afeiship" }, |
| 82 | + ], |
| 83 | + footer: { |
| 84 | + message: "基于 MIT 许可发布", |
| 85 | + copyright: "Copyright © 2019-present aric.zheng", |
| 86 | + }, |
| 87 | + }, |
| 88 | + }, |
| 89 | + en: { |
| 90 | + label: "English", |
| 91 | + lang: "en", |
| 92 | + title: "SITE_TITLE", |
| 93 | + description: "SITE_DESCRIPTION", |
| 94 | + themeConfig: { |
| 95 | + logo: "/favicon.svg", |
| 96 | + lastUpdated: { |
| 97 | + text: "Last updated", |
| 98 | + }, |
| 99 | + docFooter: { |
| 100 | + prev: "Previous", |
| 101 | + next: "Next", |
| 102 | + }, |
| 103 | + outline: { |
| 104 | + label: "On this page", |
| 105 | + level: [2, 3], |
| 106 | + }, |
| 107 | + nav: [ |
| 108 | + { text: "Home", link: "/en/" }, |
| 109 | + { text: "Components", link: "/en/posts/components/index.md" }, |
| 110 | + { text: "Utils", link: "/en/posts/utils/index.md" }, |
| 111 | + { text: "Standard", link: "/en/posts/standard/index.md" }, |
| 112 | + { text: "Incidents", link: "/en/posts/incidents/index.md" }, |
| 113 | + ], |
| 114 | + sidebar: generateSidebar({ |
| 115 | + documentRootPath: "src/en", |
| 116 | + scanStartPath: "/posts", |
| 117 | + collapsed: false, |
| 118 | + capitalizeFirst: true, |
| 119 | + useTitleFromFileHeading: true, |
| 120 | + useTitleFromFrontmatter: true, |
| 121 | + hyphenToSpace: true, |
| 122 | + excludePattern: ["README.md"], |
| 123 | + debugPrint: false, |
| 124 | + }), |
| 125 | + search: { |
| 126 | + provider: "local", |
| 127 | + options: { |
| 128 | + translations: { |
| 129 | + button: { |
| 130 | + buttonText: "Search", |
| 131 | + buttonAriaLabel: "Search documentation", |
| 132 | + }, |
| 133 | + modal: { |
| 134 | + noResultsText: "No results for", |
| 135 | + resetButtonTitle: "Reset search", |
| 136 | + footer: { |
| 137 | + selectText: "to select", |
| 138 | + navigateText: "to navigate", |
| 139 | + closeText: "to close", |
| 140 | + }, |
| 141 | + }, |
| 142 | + }, |
| 143 | + }, |
| 144 | + }, |
| 145 | + socialLinks: [ |
| 146 | + { icon: "github", link: "https://github.com/GITHUB_USERNAME" }, |
| 147 | + ], |
| 148 | + footer: { |
| 149 | + message: "Released under the MIT License.", |
| 150 | + copyright: "Copyright © 2019-present AUTHOR_NAME", |
| 151 | + }, |
| 152 | + }, |
| 153 | + }, |
| 154 | + }, |
| 155 | +}); |
0 commit comments