1
+ import { viteBundler } from '@vuepress/bundler-vite'
2
+ import { webpackBundler } from '@vuepress/bundler-webpack'
1
3
import { defineUserConfig } from '@vuepress/cli'
2
- import type { DefaultThemeOptions } from '@vuepress/theme-default'
4
+ import { docsearchPlugin } from '@vuepress/plugin-docsearch'
5
+ import { googleAnalyticsPlugin } from '@vuepress/plugin-google-analytics'
6
+ import { registerComponentsPlugin } from '@vuepress/plugin-register-components'
7
+ import { shikiPlugin } from '@vuepress/plugin-shiki'
8
+ import { defaultTheme } from '@vuepress/theme-default'
3
9
import { path } from '@vuepress/utils'
4
10
import { navbar , sidebar } from './configs'
5
11
6
12
const isProd = process . env . NODE_ENV === 'production'
7
13
8
- export default defineUserConfig < DefaultThemeOptions > ( {
14
+ export default defineUserConfig ( {
9
15
base : '/' ,
10
16
11
17
head : [
@@ -66,11 +72,9 @@ export default defineUserConfig<DefaultThemeOptions>({
66
72
67
73
bundler :
68
74
// specify bundler via environment variable
69
- process . env . DOCS_BUNDLER ??
70
- // use vite by default
71
- '@vuepress/vite' ,
75
+ process . env . DOCS_BUNDLER === 'webpack' ? webpackBundler ( ) : viteBundler ( ) ,
72
76
73
- themeConfig : {
77
+ theme : defaultTheme ( {
74
78
logo : '/images/hero.png' ,
75
79
76
80
repo : 'vuepress/vuepress-next' ,
@@ -141,7 +145,7 @@ export default defineUserConfig<DefaultThemeOptions>({
141
145
// use shiki plugin in production mode instead
142
146
prismjs : ! isProd ,
143
147
} ,
144
- } ,
148
+ } ) ,
145
149
146
150
markdown : {
147
151
importCode : {
@@ -154,81 +158,65 @@ export default defineUserConfig<DefaultThemeOptions>({
154
158
} ,
155
159
156
160
plugins : [
157
- [
158
- '@vuepress/plugin-docsearch' ,
159
- {
160
- appId : '34YFD9IUQ2' ,
161
- apiKey : '9a9058b8655746634e01071411c366b8' ,
162
- indexName : 'vuepress' ,
163
- searchParameters : {
164
- facetFilters : [ 'tags:v2' ] ,
165
- } ,
166
- locales : {
167
- '/zh/' : {
168
- placeholder : '搜索文档' ,
169
- translations : {
170
- button : {
171
- buttonText : '搜索文档' ,
172
- buttonAriaLabel : '搜索文档' ,
161
+ docsearchPlugin ( {
162
+ appId : '34YFD9IUQ2' ,
163
+ apiKey : '9a9058b8655746634e01071411c366b8' ,
164
+ indexName : 'vuepress' ,
165
+ searchParameters : {
166
+ facetFilters : [ 'tags:v2' ] ,
167
+ } ,
168
+ locales : {
169
+ '/zh/' : {
170
+ placeholder : '搜索文档' ,
171
+ translations : {
172
+ button : {
173
+ buttonText : '搜索文档' ,
174
+ buttonAriaLabel : '搜索文档' ,
175
+ } ,
176
+ modal : {
177
+ searchBox : {
178
+ resetButtonTitle : '清除查询条件' ,
179
+ resetButtonAriaLabel : '清除查询条件' ,
180
+ cancelButtonText : '取消' ,
181
+ cancelButtonAriaLabel : '取消' ,
182
+ } ,
183
+ startScreen : {
184
+ recentSearchesTitle : '搜索历史' ,
185
+ noRecentSearchesText : '没有搜索历史' ,
186
+ saveRecentSearchButtonTitle : '保存至搜索历史' ,
187
+ removeRecentSearchButtonTitle : '从搜索历史中移除' ,
188
+ favoriteSearchesTitle : '收藏' ,
189
+ removeFavoriteSearchButtonTitle : '从收藏中移除' ,
190
+ } ,
191
+ errorScreen : {
192
+ titleText : '无法获取结果' ,
193
+ helpText : '你可能需要检查你的网络连接' ,
173
194
} ,
174
- modal : {
175
- searchBox : {
176
- resetButtonTitle : '清除查询条件' ,
177
- resetButtonAriaLabel : '清除查询条件' ,
178
- cancelButtonText : '取消' ,
179
- cancelButtonAriaLabel : '取消' ,
180
- } ,
181
- startScreen : {
182
- recentSearchesTitle : '搜索历史' ,
183
- noRecentSearchesText : '没有搜索历史' ,
184
- saveRecentSearchButtonTitle : '保存至搜索历史' ,
185
- removeRecentSearchButtonTitle : '从搜索历史中移除' ,
186
- favoriteSearchesTitle : '收藏' ,
187
- removeFavoriteSearchButtonTitle : '从收藏中移除' ,
188
- } ,
189
- errorScreen : {
190
- titleText : '无法获取结果' ,
191
- helpText : '你可能需要检查你的网络连接' ,
192
- } ,
193
- footer : {
194
- selectText : '选择' ,
195
- navigateText : '切换' ,
196
- closeText : '关闭' ,
197
- searchByText : '搜索提供者' ,
198
- } ,
199
- noResultsScreen : {
200
- noResultsText : '无法找到相关结果' ,
201
- suggestedQueryText : '你可以尝试查询' ,
202
- openIssueText : '你认为该查询应该有结果?' ,
203
- openIssueLinkText : '点击反馈' ,
204
- } ,
195
+ footer : {
196
+ selectText : '选择' ,
197
+ navigateText : '切换' ,
198
+ closeText : '关闭' ,
199
+ searchByText : '搜索提供者' ,
200
+ } ,
201
+ noResultsScreen : {
202
+ noResultsText : '无法找到相关结果' ,
203
+ suggestedQueryText : '你可以尝试查询' ,
204
+ reportMissingResultsText : '你认为该查询应该有结果?' ,
205
+ reportMissingResultsLinkText : '点击反馈' ,
205
206
} ,
206
207
} ,
207
208
} ,
208
209
} ,
209
210
} ,
210
- ] ,
211
- [
212
- '@vuepress/plugin-google-analytics' ,
213
- {
214
- // we have multiple deployments, which would use different id
215
- id : process . env . DOCS_GA_ID ,
216
- } ,
217
- ] ,
218
- [
219
- '@vuepress/plugin-register-components' ,
220
- {
221
- componentsDir : path . resolve ( __dirname , './components' ) ,
222
- } ,
223
- ] ,
211
+ } ) ,
212
+ googleAnalyticsPlugin ( {
213
+ // we have multiple deployments, which would use different id
214
+ id : process . env . DOCS_GA_ID ?? '' ,
215
+ } ) ,
216
+ registerComponentsPlugin ( {
217
+ componentsDir : path . resolve ( __dirname , './components' ) ,
218
+ } ) ,
224
219
// only enable shiki plugin in production mode
225
- [
226
- '@vuepress/plugin-shiki' ,
227
- isProd
228
- ? {
229
- theme : 'dark-plus' ,
230
- }
231
- : false ,
232
- ] ,
220
+ isProd ? shikiPlugin ( { theme : 'dark-plus' } ) : [ ] ,
233
221
] ,
234
222
} )
0 commit comments