1
1
import { defineConfig } from 'vitepress'
2
- import { search as zhSearch } from './zh'
3
- import { search as ptSearch } from './pt'
4
- import { search as ruSearch } from './ru'
5
2
import { search as esSearch } from './es'
6
- import { search as koSearch } from './ko'
7
3
import { search as faSearch } from './fa'
4
+ import { search as koSearch } from './ko'
5
+ import { search as ptSearch } from './pt'
6
+ import { search as ruSearch } from './ru'
7
+ import { search as zhSearch } from './zh'
8
8
9
9
export const shared = defineConfig ( {
10
10
title : 'VitePress' ,
@@ -26,7 +26,36 @@ export const shared = defineConfig({
26
26
return code . replace ( / \[ \! \! c o d e / g, '[!code' )
27
27
}
28
28
}
29
- ]
29
+ ] ,
30
+ config ( md ) {
31
+ // TODO: remove when https://github.com/vuejs/vitepress/issues/4431 is fixed
32
+ const fence = md . renderer . rules . fence !
33
+ md . renderer . rules . fence = function ( tokens , idx , options , env , self ) {
34
+ const { localeIndex = 'root' } = env
35
+ const codeCopyButtonTitle = ( ( ) => {
36
+ switch ( localeIndex ) {
37
+ case 'es' :
38
+ return 'Copiar código'
39
+ case 'fa' :
40
+ return 'کپی کد'
41
+ case 'ko' :
42
+ return '코드 복사'
43
+ case 'pt' :
44
+ return 'Copiar código'
45
+ case 'ru' :
46
+ return 'Скопировать код'
47
+ case 'zh' :
48
+ return '复制代码'
49
+ default :
50
+ return 'Copy code'
51
+ }
52
+ } ) ( )
53
+ return fence ( tokens , idx , options , env , self ) . replace (
54
+ '<button title="Copy Code" class="copy"></button>' ,
55
+ `<button title="${ codeCopyButtonTitle } " class="copy"></button>`
56
+ )
57
+ }
58
+ }
30
59
} ,
31
60
32
61
sitemap : {
0 commit comments