|
| 1 | +import {createRequire} from 'node:module' |
| 2 | +import process from 'node:process' |
| 3 | +import {viteBundler} from '@vuepress/bundler-vite' |
| 4 | +import {docsearchPlugin} from '@vuepress/plugin-docsearch' |
| 5 | +import {baiduAnalyticsPlugin} from '@vuepress/plugin-baidu-analytics' |
| 6 | +import {registerComponentsPlugin} from '@vuepress/plugin-register-components' |
| 7 | +import {sitemapPlugin} from '@vuepress/plugin-sitemap' |
| 8 | +import {shikiPlugin} from '@vuepress/plugin-shiki' |
| 9 | +import {defaultTheme} from '@vuepress/theme-default' |
| 10 | +import {defineUserConfig} from 'vuepress' |
| 11 | +import {getDirname, path} from 'vuepress/utils' |
| 12 | +import {head, navbarZh, sidebarZh,} from './configs' |
| 13 | + |
| 14 | +const __dirname = getDirname(import.meta.url) |
| 15 | +const require = createRequire(import.meta.url) |
| 16 | +const isProd = process.env.NODE_ENV === 'production' |
| 17 | + |
| 18 | +// noinspection JSUnusedGlobalSymbols |
| 19 | +export default defineUserConfig({ |
| 20 | + // set site base to default value |
| 21 | + base: '/', |
| 22 | + |
| 23 | + // extra tags in `<head>` |
| 24 | + head, |
| 25 | + |
| 26 | + lang: 'zh-CN', |
| 27 | + |
| 28 | + title: 'SpEL Validator', |
| 29 | + description: '一个强大的 Java 参数校验包,基于 SpEL 实现,扩展自 javax.validation 包,几乎支持所有场景下的参数校验。', |
| 30 | + |
| 31 | + // specify bundler via environment variable |
| 32 | + bundler: viteBundler(), |
| 33 | + |
| 34 | + // configure default theme |
| 35 | + theme: defaultTheme({ |
| 36 | + hostname: 'https://spel-validator.sticki.cn/', |
| 37 | + logo: '/images/hero.png', |
| 38 | + repo: 'stick-i/spel-validator', |
| 39 | + docsRepo: 'stick-i/spel-validator', |
| 40 | + docsDir: 'document/web-docs/docs', |
| 41 | + docsBranch: 'docs', |
| 42 | + |
| 43 | + // theme-level locales config |
| 44 | + locales: { |
| 45 | + |
| 46 | + /** |
| 47 | + * Chinese locale config |
| 48 | + */ |
| 49 | + '/': { |
| 50 | + // navbar |
| 51 | + navbar: navbarZh, |
| 52 | + selectLanguageName: '简体中文', |
| 53 | + selectLanguageText: '选择语言', |
| 54 | + selectLanguageAriaLabel: '选择语言', |
| 55 | + // sidebar |
| 56 | + sidebar: sidebarZh, |
| 57 | + // page meta |
| 58 | + editLinkText: '在 GitHub 上编辑此页', |
| 59 | + lastUpdatedText: '上次更新', |
| 60 | + contributorsText: '贡献者', |
| 61 | + // custom containers |
| 62 | + tip: '提示', |
| 63 | + warning: '注意', |
| 64 | + danger: '警告', |
| 65 | + // 404 page |
| 66 | + notFound: [ |
| 67 | + '这里什么都没有', |
| 68 | + '我们怎么到这来了?', |
| 69 | + '这是一个 404 页面', |
| 70 | + '看起来我们进入了错误的链接', |
| 71 | + ], |
| 72 | + backToHome: '返回首页', |
| 73 | + // a11y |
| 74 | + openInNewWindow: '在新窗口打开', |
| 75 | + toggleColorMode: '切换颜色模式', |
| 76 | + toggleSidebar: '切换侧边栏', |
| 77 | + }, |
| 78 | + }, |
| 79 | + |
| 80 | + themePlugins: { |
| 81 | + // only enable git plugin in production mode |
| 82 | + git: isProd, |
| 83 | + // use shiki plugin in production mode instead |
| 84 | + prismjs: !isProd, |
| 85 | + }, |
| 86 | + }), |
| 87 | + |
| 88 | + // configure markdown |
| 89 | + markdown: { |
| 90 | + importCode: { |
| 91 | + handleImportPath: (importPath) => { |
| 92 | + // handle @vuepress packages import path |
| 93 | + if (importPath.startsWith('@vuepress/')) { |
| 94 | + const packageName = importPath.match(/^(@vuepress\/[^/]*)/)![1] |
| 95 | + return importPath |
| 96 | + .replace( |
| 97 | + packageName, |
| 98 | + path.dirname(require.resolve(`${packageName}/package.json`)), |
| 99 | + ) |
| 100 | + .replace('/src/', '/lib/') |
| 101 | + .replace(/hotKey\.ts$/, 'hotKey.d.ts') |
| 102 | + } |
| 103 | + return importPath |
| 104 | + }, |
| 105 | + }, |
| 106 | + }, |
| 107 | + |
| 108 | + // use plugins |
| 109 | + plugins: [ |
| 110 | + docsearchPlugin({ |
| 111 | + appId: '', |
| 112 | + apiKey: '', |
| 113 | + indexName: 'spel-validator', |
| 114 | + searchParameters: { |
| 115 | + facetFilters: ['tags:v2'], |
| 116 | + }, |
| 117 | + locales: { |
| 118 | + '/': { |
| 119 | + placeholder: '搜索文档', |
| 120 | + translations: { |
| 121 | + button: { |
| 122 | + buttonText: '搜索文档', |
| 123 | + buttonAriaLabel: '搜索文档', |
| 124 | + }, |
| 125 | + modal: { |
| 126 | + searchBox: { |
| 127 | + resetButtonTitle: '清除查询条件', |
| 128 | + resetButtonAriaLabel: '清除查询条件', |
| 129 | + cancelButtonText: '取消', |
| 130 | + cancelButtonAriaLabel: '取消', |
| 131 | + }, |
| 132 | + startScreen: { |
| 133 | + recentSearchesTitle: '搜索历史', |
| 134 | + noRecentSearchesText: '没有搜索历史', |
| 135 | + saveRecentSearchButtonTitle: '保存至搜索历史', |
| 136 | + removeRecentSearchButtonTitle: '从搜索历史中移除', |
| 137 | + favoriteSearchesTitle: '收藏', |
| 138 | + removeFavoriteSearchButtonTitle: '从收藏中移除', |
| 139 | + }, |
| 140 | + errorScreen: { |
| 141 | + titleText: '无法获取结果', |
| 142 | + helpText: '你可能需要检查你的网络连接', |
| 143 | + }, |
| 144 | + footer: { |
| 145 | + selectText: '选择', |
| 146 | + navigateText: '切换', |
| 147 | + closeText: '关闭', |
| 148 | + searchByText: '搜索提供者', |
| 149 | + }, |
| 150 | + noResultsScreen: { |
| 151 | + noResultsText: '无法找到相关结果', |
| 152 | + suggestedQueryText: '你可以尝试查询', |
| 153 | + reportMissingResultsText: '你认为该查询应该有结果?', |
| 154 | + reportMissingResultsLinkText: '点击反馈', |
| 155 | + }, |
| 156 | + }, |
| 157 | + }, |
| 158 | + }, |
| 159 | + }, |
| 160 | + }), |
| 161 | + baiduAnalyticsPlugin({ |
| 162 | + id: '1d5d746b39da6a27516834e6529b02e6', |
| 163 | + }), |
| 164 | + registerComponentsPlugin({ |
| 165 | + componentsDir: path.resolve(__dirname, './components'), |
| 166 | + }), |
| 167 | + sitemapPlugin({ |
| 168 | + hostname: 'spel-validator.sticki.cn', |
| 169 | + }), |
| 170 | + // only enable shiki plugin in production mode |
| 171 | + isProd |
| 172 | + ? shikiPlugin({ |
| 173 | + langs: ['bash', 'diff', 'json', 'md', 'ts', 'vue'], |
| 174 | + theme: 'dark-plus', |
| 175 | + }) |
| 176 | + : [], |
| 177 | + ], |
| 178 | +}) |
0 commit comments