11import { defineConfig } from 'vitepress'
2- import renderPermaLink from './render-perma-link'
3- import MarkDownItCustomAnchor from './markdown-it-custom-anchor'
42
53const ogDescription = 'Next Generation Frontend Tooling'
64const ogImage = 'https://vitejs.dev/og-image.png'
75const ogTitle = 'Vite'
86const ogUrl = 'https://vitejs.dev'
97
8+ // netlify envs
9+ const deployURL = process . env . DEPLOY_PRIME_URL || ''
10+ const commitRef = process . env . COMMIT_REF ?. slice ( 0 , 8 ) || 'dev'
11+
12+ const deployType = ( ( ) => {
13+ switch ( deployURL ) {
14+ case 'https://main--vite-docs-main.netlify.app' :
15+ return 'main'
16+ case '' :
17+ return 'local'
18+ default :
19+ return 'release'
20+ }
21+ } ) ( )
22+ const additionalTitle = ( ( ) : string => {
23+ switch ( deployType ) {
24+ case 'main' :
25+ return ' (main branch)'
26+ case 'local' :
27+ return ' (local)'
28+ case 'release' :
29+ return ''
30+ }
31+ } ) ( )
32+ const versionLinks = ( ( ) : DefaultTheme . NavItemWithLink [ ] => {
33+ const oldVersions : DefaultTheme . NavItemWithLink [ ] = [
34+ {
35+ text : 'Vite 4 Docs' ,
36+ link : 'https://v4.vitejs.dev' ,
37+ } ,
38+ {
39+ text : 'Vite 3 Docs' ,
40+ link : 'https://v3.vitejs.dev' ,
41+ } ,
42+ {
43+ text : 'Vite 2 Docs' ,
44+ link : 'https://v2.vitejs.dev' ,
45+ } ,
46+ ]
47+
48+ switch ( deployType ) {
49+ case 'main' :
50+ case 'local' :
51+ return [
52+ {
53+ text : 'Vite 5 Docs (release)' ,
54+ link : 'https://vitejs.dev' ,
55+ } ,
56+ ...oldVersions ,
57+ ]
58+ case 'release' :
59+ return oldVersions
60+ }
61+ } ) ( )
62+
1063export default defineConfig ( {
1164 title : 'Vite 官方中文文档' ,
1265 description : '下一代前端工具链' ,
@@ -40,6 +93,7 @@ export default defineConfig({
4093 es : { label : 'Español' , link : 'https://es.vitejs.dev' } ,
4194 pt : { label : 'Português' , link : 'https://pt.vitejs.dev' } ,
4295 ko : { label : '한국어' , link : 'https://ko.vitejs.dev' } ,
96+ de : { label : 'Deutsch' , link : 'https://de.vitejs.dev' } ,
4397 } ,
4498
4599 themeConfig : {
@@ -51,7 +105,8 @@ export default defineConfig({
51105 } ,
52106
53107 outline : {
54- label : '本页目录'
108+ label : '本页目录' ,
109+ level : [ 2 , 3 ] ,
55110 } ,
56111
57112 socialLinks : [
@@ -127,31 +182,44 @@ export default defineConfig({
127182 text : '相关链接' ,
128183 items : [
129184 { text : 'Team' , link : '/team' } ,
185+ { text : 'Blog' , link : '/blog' } ,
130186 { text : 'Releases' , link : '/releases' } ,
131187 {
132- text : 'Twitter' ,
133- link : 'https://twitter.com/vite_js'
134- } ,
135- {
136- text : 'Discord Chat' ,
137- link : 'https://chat.vitejs.dev'
138- } ,
139- {
140- text : 'Awesome Vite' ,
141- link : 'https://github.com/vitejs/awesome-vite'
142- } ,
143- {
144- text : 'Dev.to 社区' ,
145- link : 'https://dev.to/t/vite'
188+ items : [
189+ {
190+ text : 'Twitter' ,
191+ link : 'https://twitter.com/vite_js' ,
192+ } ,
193+ {
194+ text : 'Discord 聊天室' ,
195+ link : 'https://chat.vitejs.dev'
196+ } ,
197+ {
198+ text : 'Awesome Vite' ,
199+ link : 'https://github.com/vitejs/awesome-vite'
200+ } ,
201+ {
202+ text : 'ViteConf' ,
203+ link : 'https://viteconf.org' ,
204+ } ,
205+ {
206+ text : 'Dev.to 社区' ,
207+ link : 'https://dev.to/t/vite'
208+ } ,
209+ {
210+ text : 'Rollup 插件兼容' ,
211+ link : 'https://vite-rollup-plugins.patak.dev/'
212+ } ,
213+ {
214+ text : '更新日志' ,
215+ link : 'https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md'
216+ } ,
217+ {
218+ text : '贡献指南' ,
219+ link : 'https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md' ,
220+ } ,
221+ ] ,
146222 } ,
147- {
148- text : 'Rollup 插件兼容' ,
149- link : 'https://vite-rollup-plugins.patak.dev/'
150- } ,
151- {
152- text : '更新日志' ,
153- link : 'https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md'
154- }
155223 ]
156224 } ,
157225 {
@@ -230,12 +298,16 @@ export default defineConfig({
230298 text : '故障排除' ,
231299 link : '/guide/troubleshooting'
232300 } ,
301+ {
302+ text : '性能' ,
303+ link : '/guide/performance' ,
304+ } ,
233305 {
234306 text : '理念' ,
235307 link : '/guide/philosophy' ,
236308 } ,
237309 {
238- text : '从 v3 迁移' ,
310+ text : '从 v4 迁移' ,
239311 link : '/guide/migration'
240312 } ,
241313 ] ,
@@ -296,11 +368,11 @@ export default defineConfig({
296368 } ,
297369 {
298370 text : 'Worker 选项' ,
299- link : '/config/worker-options'
300- }
301- ]
302- }
303- ]
304- }
371+ link : '/config/worker-options' ,
372+ } ,
373+ ] ,
374+ } ,
375+ ] ,
376+ } ,
305377 } ,
306378} )
0 commit comments