forked from vuejs-translations/docs-zh-cn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.ts
717 lines (701 loc) · 17.5 KB
/
config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
import fs from 'fs'
import path from 'path'
import { defineConfigWithTheme } from 'vitepress'
import type { Config as ThemeConfig } from '@vue/theme'
import baseConfig from '@vue/theme/config'
import { headerPlugin } from './headerMdPlugin'
import { jobsPlugin } from './jobsMdPlugin'
const nav: ThemeConfig['nav'] = [
{
text: '文档',
activeMatch: `^/(guide|style-guide|cookbook|examples)/`,
items: [
{ text: '深度指南', link: '/guide/introduction' },
{ text: '互动教程', link: '/tutorial/' },
{ text: '示例', link: '/examples/' },
{ text: '快速上手', link: '/guide/quick-start' },
// { text: '风格指南', link: '/style-guide/' },
{
text: 'Vue 2 文档',
link: 'https://v2.cn.vuejs.org'
},
{
text: '从 Vue 2 迁移',
link: 'https://v3-migration.vuejs.org/'
}
]
},
{
text: 'API',
activeMatch: `^/api/`,
link: '/api/'
},
{
text: '演练场',
link: 'https://sfc.vuejs.org'
},
{
text: '生态系统',
activeMatch: `^/ecosystem/`,
items: [
{
text: '资源',
items: [
{ text: '合作伙伴', link: '/partners/' },
{ text: '主题', link: '/ecosystem/themes' },
{ text: '找工作', link: 'https://vuejobs.com/?ref=vuejs' },
{ text: 'T-Shirt 商店', link: 'https://vue.threadless.com/' }
]
},
{
text: '官方库',
items: [
{ text: 'Vue Router', link: 'https://router.vuejs.org/zh/' },
{ text: 'Pinia', link: 'https://pinia.vuejs.org/' },
{ text: '工具链指南', link: '/guide/scaling-up/tooling.html' }
]
},
{
text: '视频课程',
items: [
{
text: 'Vue Mastery',
link: 'https://www.vuemastery.com/courses/'
},
{
text: 'Vue School',
link: 'https://vueschool.io/?friend=vuejs&utm_source=Vuejs.org&utm_medium=Link&utm_content=Navbar%20Dropdown'
}
]
},
{
text: '帮助',
items: [
{
text: 'Discord 聊天室',
link: 'https://discord.com/invite/HBherRA'
},
{
text: 'GitHub 论坛',
link: 'https://github.com/vuejs/core/discussions'
},
{ text: 'DEV Community', link: 'https://dev.to/t/vue' }
]
},
{
text: '动态',
items: [
{ text: '博客', link: 'https://blog.vuejs.org/' },
{ text: 'Twitter', link: 'https://twitter.com/vuejs' },
{ text: '新闻', link: 'https://news.vuejs.org/' },
{ text: '活动', link: 'https://events.vuejs.org/' }
]
}
]
},
{
text: '关于',
activeMatch: `^/about/`,
items: [
{ text: '常见问题', link: '/about/faq' },
{ text: '团队', link: '/about/team' },
{ text: '版本发布', link: '/about/releases' },
{
text: '社区指南',
link: '/about/community-guide'
},
{ text: '行为规范', link: 'https://vuejs.org/about/coc.html' },
{
text: '纪录片',
link: 'https://www.youtube.com/watch?v=OrxmtDw4pVI'
}
]
},
{
text: '赞助',
link: '/sponsor/'
},
{
text: '合作伙伴',
link: '/partners/',
activeMatch: `^/partners/`
}
]
export const sidebar: ThemeConfig['sidebar'] = {
'/guide/': [
{
text: '开始',
items: [
{ text: '简介', link: '/guide/introduction' },
{
text: '快速上手',
link: '/guide/quick-start'
}
]
},
{
text: '基础',
items: [
{
text: '创建一个应用',
link: '/guide/essentials/application'
},
{
text: '模板语法',
link: '/guide/essentials/template-syntax'
},
{
text: '响应式基础',
link: '/guide/essentials/reactivity-fundamentals'
},
{
text: '计算属性',
link: '/guide/essentials/computed'
},
{
text: '类与样式绑定',
link: '/guide/essentials/class-and-style'
},
{
text: '条件渲染',
link: '/guide/essentials/conditional'
},
{ text: '列表渲染', link: '/guide/essentials/list' },
{
text: '事件处理',
link: '/guide/essentials/event-handling'
},
{ text: '表单输入绑定', link: '/guide/essentials/forms' },
{
text: '生命周期',
link: '/guide/essentials/lifecycle'
},
{ text: '侦听器', link: '/guide/essentials/watchers' },
{ text: '模板引用', link: '/guide/essentials/template-refs' },
{
text: '组件基础',
link: '/guide/essentials/component-basics'
}
]
},
{
text: '深入组件',
items: [
{
text: '注册',
link: '/guide/components/registration'
},
{ text: 'Props', link: '/guide/components/props' },
{ text: '事件', link: '/guide/components/events' },
{
text: '透传 Attributes',
link: '/guide/components/attrs'
},
{ text: '插槽', link: '/guide/components/slots' },
{
text: '依赖注入',
link: '/guide/components/provide-inject'
},
{
text: '异步组件',
link: '/guide/components/async'
}
]
},
{
text: '逻辑复用',
items: [
{
text: '组合式函数',
link: '/guide/reusability/composables'
},
{
text: '自定义指令',
link: '/guide/reusability/custom-directives'
},
{ text: '插件', link: '/guide/reusability/plugins' }
]
},
{
text: '内置组件',
items: [
{ text: 'Transition', link: '/guide/built-ins/transition' },
{
text: 'TransitionGroup',
link: '/guide/built-ins/transition-group'
},
{ text: 'KeepAlive', link: '/guide/built-ins/keep-alive' },
{ text: 'Teleport', link: '/guide/built-ins/teleport' },
{ text: 'Suspense', link: '/guide/built-ins/suspense' }
]
},
{
text: '应用规模化',
items: [
{ text: '单文件组件', link: '/guide/scaling-up/sfc' },
{ text: '工具链', link: '/guide/scaling-up/tooling' },
{ text: '路由', link: '/guide/scaling-up/routing' },
{
text: '状态管理',
link: '/guide/scaling-up/state-management'
},
{ text: '测试', link: '/guide/scaling-up/testing' },
{
text: '服务端渲染 (SSR)',
link: '/guide/scaling-up/ssr'
}
]
},
{
text: '最佳实践',
items: [
{
text: '生产部署',
link: '/guide/best-practices/production-deployment'
},
{
text: '性能优化',
link: '/guide/best-practices/performance'
},
{
text: '无障碍访问',
link: '/guide/best-practices/accessibility'
},
{
text: '安全',
link: '/guide/best-practices/security'
}
]
},
{
text: 'TypeScript',
items: [
{ text: '总览', link: '/guide/typescript/overview' },
{
text: 'TS 与组合式 API',
link: '/guide/typescript/composition-api'
},
{
text: 'TS 与选项式 API',
link: '/guide/typescript/options-api'
}
]
},
{
text: '进阶主题',
items: [
{
text: '使用 Vue 的多种方式',
link: '/guide/extras/ways-of-using-vue'
},
{
text: '组合式 API 常见问答',
link: '/guide/extras/composition-api-faq'
},
{
text: '深入响应式系统',
link: '/guide/extras/reactivity-in-depth'
},
{
text: '渲染机制',
link: '/guide/extras/rendering-mechanism'
},
{
text: '渲染函数 & JSX',
link: '/guide/extras/render-function'
},
{
text: 'Vue 与 Web Components',
link: '/guide/extras/web-components'
},
{
text: '动画技巧',
link: '/guide/extras/animation'
},
{
text: '响应性语法糖',
link: '/guide/extras/reactivity-transform'
}
// {
// text: '为 Vue 构建一个库',
// link: '/guide/extras/building-a-library'
// },
// { text: 'Custom Renderers', link: '/guide/extras/custom-renderer' },
// {
// text: 'Vue for React 开发者',
// link: '/guide/extras/vue-for-react-devs'
// }
]
}
],
'/api/': [
{
text: '全局 API',
items: [
{ text: '应用实例', link: '/api/application' },
{
text: '通用',
link: '/api/general'
}
]
},
{
text: '组合式 API',
items: [
{ text: 'setup()', link: '/api/composition-api-setup' },
{
text: '响应式: 核心',
link: '/api/reactivity-core'
},
{
text: '响应式: 工具',
link: '/api/reactivity-utilities'
},
{
text: '响应式: 进阶',
link: '/api/reactivity-advanced'
},
{
text: '生命周期钩子',
link: '/api/composition-api-lifecycle'
},
{
text: '依赖注入',
link: '/api/composition-api-dependency-injection'
}
]
},
{
text: '选项式 API',
items: [
{ text: '状态选项', link: '/api/options-state' },
{ text: '渲染选项', link: '/api/options-rendering' },
{
text: '生命周期选项',
link: '/api/options-lifecycle'
},
{
text: '组合选项',
link: '/api/options-composition'
},
{ text: '其他杂项', link: '/api/options-misc' },
{
text: '组件实例',
link: '/api/component-instance'
}
]
},
{
text: '内置内容',
items: [
{ text: '指令', link: '/api/built-in-directives' },
{ text: '组件', link: '/api/built-in-components' },
{
text: '特殊元素',
link: '/api/built-in-special-elements'
},
{
text: '特殊 Attributes',
link: '/api/built-in-special-attributes'
}
]
},
{
text: '单文件组件',
items: [
{ text: '语法定义', link: '/api/sfc-spec' },
{ text: '<script setup>', link: '/api/sfc-script-setup' },
{ text: 'CSS 功能', link: '/api/sfc-css-features' }
]
},
{
text: '进阶 API',
items: [
{ text: '渲染函数', link: '/api/render-function' },
{ text: '服务端渲染', link: '/api/ssr' },
{ text: 'TypeScript 工具类型', link: '/api/utility-types' },
{ text: '自定义渲染', link: '/api/custom-renderer' }
]
}
],
'/examples/': [
{
text: '基础',
items: [
{
text: '你好,世界',
link: '/examples/#hello-world'
},
{
text: '处理用户输入',
link: '/examples/#handling-input'
},
{
text: 'Attribute 绑定',
link: '/examples/#attribute-bindings'
},
{
text: '条件与循环',
link: '/examples/#conditionals-and-loops'
},
{
text: '表单绑定',
link: '/examples/#form-bindings'
},
{
text: '简单组件',
link: '/examples/#simple-component'
}
]
},
{
text: '实战',
items: [
{
text: 'Markdown 编辑器',
link: '/examples/#markdown'
},
{
text: '获取数据',
link: '/examples/#fetching-data'
},
{
text: '带有排序和过滤器的网格',
link: '/examples/#grid'
},
{
text: '树状视图',
link: '/examples/#tree'
},
{
text: 'SVG 图像',
link: '/examples/#svg'
},
{
text: '带过渡动效的模态框',
link: '/examples/#modal'
},
{
text: '带过渡动效的列表',
link: '/examples/#list-transition'
},
{
text: 'TodoMVC',
link: '/examples/#todomvc'
}
]
},
{
// https://eugenkiss.github.io/7guis/
text: '7 GUIs',
items: [
{
text: '计数器',
link: '/examples/#counter'
},
{
text: '温度转换器',
link: '/examples/#temperature-converter'
},
{
text: '机票预订',
link: '/examples/#flight-booker'
},
{
text: '计时器',
link: '/examples/#timer'
},
{
text: 'CRUD',
link: '/examples/#crud'
},
{
text: '画圆',
link: '/examples/#circle-drawer'
},
{
text: '单元格',
link: '/examples/#cells'
}
]
}
],
'/style-guide/': [
{
text: 'Style Guide',
items: [
{
text: 'Overview',
link: '/style-guide/'
},
{
text: 'A - Essential',
link: '/style-guide/rules-essential'
},
{
text: 'B - Strongly Recommended',
link: '/style-guide/rules-strongly-recommended'
},
{
text: 'C - Recommended',
link: '/style-guide/rules-recommended'
},
{
text: 'D - Use with Caution',
link: '/style-guide/rules-use-with-caution'
}
]
}
]
}
const i18n: ThemeConfig['i18n'] = {
search: '搜索',
menu: '菜单',
toc: '本页目录',
returnToTop: '返回顶部',
appearance: '外观',
previous: '前一篇',
next: '下一篇',
pageNotFound: '页面未找到',
deadLink: {
before: '你打开了一个不存在的链接:',
after: '。'
},
deadLinkReport: {
before: '不介意的话请提交到',
link: '这里',
after: ',我们会跟进修复。'
},
footerLicense: {
before: '',
after: ''
},
// aria labels
// TODO:
// update the key to `ariaAnnouncer` after new `@vue/theme` released
// https://github.com/vuejs/theme/issues/75
ariaAnnouner: {
before: '',
after: '已经加载完毕'
},
ariaDarkMode: '切换深色模式',
ariaSkipToContent: '直接跳到内容',
ariaToC: '当前页面的目录',
ariaMainNav: '主导航',
ariaMobileNav: '移动版导航',
ariaSidebarNav: '侧边栏导航',
}
export default defineConfigWithTheme<ThemeConfig>({
extends: baseConfig,
lang: 'zh-CN',
title: 'Vue.js',
description: 'Vue.js - 渐进式的 JavaScript 框架',
srcDir: 'src',
srcExclude: ['tutorial/**/description.md'],
scrollOffset: 'header',
head: [
['meta', { name: 'theme-color', content: '#3c8772' }],
['meta', { name: 'twitter:site', content: '@vuejs' }],
['meta', { name: 'twitter:card', content: 'summary' }],
[
'meta',
{
name: 'twitter:image',
content: 'https://vuejs.org/images/logo.png'
}
],
[
'link',
{
rel: 'preconnect',
href: 'https://sponsors.vuejs.org'
}
],
[
'script',
{},
fs.readFileSync(
path.resolve(__dirname, './inlined-scripts/restorePreference.js'),
'utf-8'
)
],
[
'script',
{
src: 'https://cdn.usefathom.com/script.js',
'data-site': 'ZPMMDSYA',
'data-spa': 'auto',
defer: ''
}
]
],
themeConfig: {
nav,
sidebar,
i18n,
algolia: {
indexName: 'vuejs_cn2',
appId: 'UURH1MHAF7',
apiKey: 'c23eb8e7895f42daeaf2bf6f63eb4bf6',
searchParameters: {
facetFilters: ['version:v3']
}
},
// carbonAds: {
// code: 'CEBDT27Y',
// placement: 'vuejsorg'
// },
socialLinks: [
{ icon: 'languages', link: '/translations/' },
{ icon: 'github', link: 'https://github.com/vuejs/' },
{ icon: 'twitter', link: 'https://twitter.com/vuejs' },
{ icon: 'discord', link: 'https://discord.com/invite/HBherRA' }
],
editLink: {
repo: 'vuejs-translations/docs-zh-cn',
text: '在 GitHub 上编辑此页'
},
footer: {
license: {
text: '版权声明',
link: 'https://github.com/vuejs-translations/docs-zh-cn#%E7%89%88%E6%9D%83%E5%A3%B0%E6%98%8E'
},
copyright: `本中文文档内容版权为 Vue 官方团队及翻译贡献者所有,保留所有权利。`
}
},
markdown: {
config(md) {
md.use(headerPlugin).use(jobsPlugin)
}
},
vite: {
define: {
__VUE_OPTIONS_API__: false
},
optimizeDeps: {
include: ['gsap', 'dynamics.js'],
exclude: ['@vue/repl']
},
// @ts-ignore
ssr: {
external: ['@vue/repl']
},
server: {
host: true,
fs: {
// for when developing with locally linked theme
allow: ['../..']
}
},
build: {
minify: 'terser',
chunkSizeWarningLimit: Infinity
},
json: {
stringify: true
}
},
vue: {
reactivityTransform: true
}
})