11import {
22 defineConfig ,
33 resolveSiteDataByRoute ,
4- type ConfigEnv ,
54 type HeadConfig
65} from 'vitepress'
76import {
@@ -13,160 +12,159 @@ import llmstxt from 'vitepress-plugin-llms'
1312
1413const prod = ! ! process . env . NETLIFY
1514
16- export default ( ctx : ConfigEnv ) =>
17- defineConfig ( {
18- title : 'VitePress' ,
15+ export default defineConfig ( {
16+ title : 'VitePress' ,
1917
20- rewrites : {
21- 'en/:rest*' : ':rest*'
22- } ,
18+ rewrites : {
19+ 'en/:rest*' : ':rest*'
20+ } ,
2321
24- lastUpdated : true ,
25- cleanUrls : true ,
26- metaChunk : true ,
22+ lastUpdated : true ,
23+ cleanUrls : true ,
24+ metaChunk : true ,
2725
28- markdown : {
29- math : true ,
30- codeTransformers : [
31- // We use `[!!code` in demo to prevent transformation, here we revert it back.
32- {
33- postprocess ( code ) {
34- return code . replace ( / \[ \! \! c o d e / g, '[!code' )
35- }
26+ markdown : {
27+ math : true ,
28+ codeTransformers : [
29+ // We use `[!!code` in demo to prevent transformation, here we revert it back.
30+ {
31+ postprocess ( code ) {
32+ return code . replace ( / \[ \! \! c o d e / g, '[!code' )
3633 }
37- ] ,
38- config ( md ) {
39- // TODO: remove when https://github.com/vuejs/vitepress/issues/4431 is fixed
40- const fence = md . renderer . rules . fence !
41- md . renderer . rules . fence = function ( tokens , idx , options , env , self ) {
42- const { localeIndex = 'root' } = env
43- const codeCopyButtonTitle = ( ( ) => {
44- switch ( localeIndex ) {
45- case 'es' :
46- return 'Copiar código'
47- case 'fa' :
48- return 'کپی کد'
49- case 'ko' :
50- return '코드 복사'
51- case 'pt' :
52- return 'Copiar código'
53- case 'ru' :
54- return 'Скопировать код'
55- case 'zh' :
56- return '复制代码'
57- default :
58- return 'Copy code'
59- }
60- } ) ( )
61- return fence ( tokens , idx , options , env , self ) . replace (
62- '<button title="Copy Code" class="copy"></button>' ,
63- `<button title="${ codeCopyButtonTitle } " class="copy"></button>`
64- )
65- }
66- md . use ( groupIconMdPlugin )
6734 }
68- } ,
69-
70- sitemap : {
71- hostname : 'https://vitepress.dev' ,
72- transformItems ( items ) {
73- return items . filter ( ( item ) => ! item . url . includes ( 'migration' ) )
35+ ] ,
36+ config ( md ) {
37+ // TODO: remove when https://github.com/vuejs/vitepress/issues/4431 is fixed
38+ const fence = md . renderer . rules . fence !
39+ md . renderer . rules . fence = function ( tokens , idx , options , env , self ) {
40+ const { localeIndex = 'root' } = env
41+ const codeCopyButtonTitle = ( ( ) => {
42+ switch ( localeIndex ) {
43+ case 'es' :
44+ return 'Copiar código'
45+ case 'fa' :
46+ return 'کپی کد'
47+ case 'ko' :
48+ return '코드 복사'
49+ case 'pt' :
50+ return 'Copiar código'
51+ case 'ru' :
52+ return 'Скопировать код'
53+ case 'zh' :
54+ return '复制代码'
55+ default :
56+ return 'Copy code'
57+ }
58+ } ) ( )
59+ return fence ( tokens , idx , options , env , self ) . replace (
60+ '<button title="Copy Code" class="copy"></button>' ,
61+ `<button title="${ codeCopyButtonTitle } " class="copy"></button>`
62+ )
7463 }
75- } ,
64+ md . use ( groupIconMdPlugin )
65+ }
66+ } ,
7667
77- head : [
78- [
79- 'link' ,
80- { rel : 'icon' , type : 'image/svg+xml' , href : '/vitepress-logo-mini.svg' }
81- ] ,
82- [
83- 'link' ,
84- { rel : 'icon' , type : 'image/png' , href : '/vitepress-logo-mini.png' }
85- ] ,
86- [ 'meta' , { name : 'theme-color' , content : '#5f67ee' } ] ,
87- [ 'meta' , { property : 'og:type' , content : 'website' } ] ,
88- [ 'meta' , { property : 'og:site_name' , content : 'VitePress' } ] ,
89- [
90- 'meta' ,
91- {
92- property : 'og:image' ,
93- content : 'https://vitepress.dev/vitepress-og.jpg'
94- }
95- ] ,
96- [ 'meta' , { property : 'og:url' , content : 'https://vitepress.dev/' } ] ,
97- [
98- 'script' ,
99- {
100- src : 'https://cdn.usefathom.com/script.js' ,
101- 'data-site' : 'AZBRSFGG' ,
102- 'data-spa' : 'auto' ,
103- defer : ''
104- }
105- ]
106- ] ,
68+ sitemap : {
69+ hostname : 'https://vitepress.dev' ,
70+ transformItems ( items ) {
71+ return items . filter ( ( item ) => ! item . url . includes ( 'migration' ) )
72+ }
73+ } ,
10774
108- themeConfig : {
109- logo : { src : '/vitepress-logo-mini.svg' , width : 24 , height : 24 } ,
75+ head : [
76+ [
77+ 'link' ,
78+ { rel : 'icon' , type : 'image/svg+xml' , href : '/vitepress-logo-mini.svg' }
79+ ] ,
80+ [
81+ 'link' ,
82+ { rel : 'icon' , type : 'image/png' , href : '/vitepress-logo-mini.png' }
83+ ] ,
84+ [ 'meta' , { name : 'theme-color' , content : '#5f67ee' } ] ,
85+ [ 'meta' , { property : 'og:type' , content : 'website' } ] ,
86+ [ 'meta' , { property : 'og:site_name' , content : 'VitePress' } ] ,
87+ [
88+ 'meta' ,
89+ {
90+ property : 'og:image' ,
91+ content : 'https://vitepress.dev/vitepress-og.jpg'
92+ }
93+ ] ,
94+ [ 'meta' , { property : 'og:url' , content : 'https://vitepress.dev/' } ] ,
95+ [
96+ 'script' ,
97+ {
98+ src : 'https://cdn.usefathom.com/script.js' ,
99+ 'data-site' : 'AZBRSFGG' ,
100+ 'data-spa' : 'auto' ,
101+ defer : ''
102+ }
103+ ]
104+ ] ,
110105
111- socialLinks : [
112- { icon : 'github' , link : 'https://github.com/vuejs/vitepress' }
113- ] ,
106+ themeConfig : {
107+ logo : { src : '/vitepress-logo-mini.svg' , width : 24 , height : 24 } ,
114108
115- search : {
116- provider : 'algolia' ,
117- options : {
118- appId : '8J64VVRP8K' ,
119- apiKey : '52f578a92b88ad6abde815aae2b0ad7c' ,
120- indexName : 'vitepress'
121- }
122- } ,
109+ socialLinks : [
110+ { icon : 'github' , link : 'https://github.com/vuejs/vitepress' }
111+ ] ,
123112
124- carbonAds : { code : 'CEBDT27Y' , placement : 'vuejsorg' }
113+ search : {
114+ provider : 'algolia' ,
115+ options : {
116+ appId : '8J64VVRP8K' ,
117+ apiKey : '52f578a92b88ad6abde815aae2b0ad7c' ,
118+ indexName : 'vitepress'
119+ }
125120 } ,
126121
127- locales : {
128- root : { label : 'English' } ,
129- zh : { label : '简体中文' } ,
130- pt : { label : 'Português' } ,
131- ru : { label : 'Русский' } ,
132- es : { label : 'Español' } ,
133- ko : { label : '한국어' } ,
134- fa : { label : 'فارسی' }
135- } ,
122+ carbonAds : { code : 'CEBDT27Y' , placement : 'vuejsorg' }
123+ } ,
136124
137- vite : {
138- plugins : [
139- groupIconVitePlugin ( {
140- customIcon : {
141- vitepress : localIconLoader (
142- import . meta. url ,
143- '../public/vitepress-logo-mini.svg'
144- ) ,
145- firebase : 'logos:firebase'
146- }
147- } ) ,
148- prod &&
149- llmstxt ( {
150- workDir : 'en' ,
151- ignoreFiles : [ 'index.md' ]
152- } )
153- ] ,
154- experimental : {
155- enableNativePlugin : ctx . command === 'build'
156- }
157- } ,
125+ locales : {
126+ root : { label : 'English' } ,
127+ zh : { label : '简体中文' } ,
128+ pt : { label : 'Português' } ,
129+ ru : { label : 'Русский' } ,
130+ es : { label : 'Español' } ,
131+ ko : { label : '한국어' } ,
132+ fa : { label : 'فارسی' }
133+ } ,
158134
159- transformPageData : prod
160- ? ( pageData , ctx ) => {
161- const site = resolveSiteDataByRoute (
162- ctx . siteConfig . site ,
163- pageData . relativePath
164- )
165- const title = `${ pageData . title || site . title } | ${ pageData . description || site . description } `
166- ; ( ( pageData . frontmatter . head ??= [ ] ) as HeadConfig [ ] ) . push (
167- [ 'meta' , { property : 'og:locale' , content : site . lang } ] ,
168- [ 'meta' , { property : 'og:title' , content : title } ]
169- )
135+ vite : {
136+ plugins : [
137+ groupIconVitePlugin ( {
138+ customIcon : {
139+ vitepress : localIconLoader (
140+ import . meta. url ,
141+ '../public/vitepress-logo-mini.svg'
142+ ) ,
143+ firebase : 'logos:firebase'
170144 }
171- : undefined
172- } )
145+ } ) ,
146+ prod &&
147+ llmstxt ( {
148+ workDir : 'en' ,
149+ ignoreFiles : [ 'index.md' ]
150+ } )
151+ ] ,
152+ experimental : {
153+ enableNativePlugin : true
154+ }
155+ } ,
156+
157+ transformPageData : prod
158+ ? ( pageData , ctx ) => {
159+ const site = resolveSiteDataByRoute (
160+ ctx . siteConfig . site ,
161+ pageData . relativePath
162+ )
163+ const title = `${ pageData . title || site . title } | ${ pageData . description || site . description } `
164+ ; ( ( pageData . frontmatter . head ??= [ ] ) as HeadConfig [ ] ) . push (
165+ [ 'meta' , { property : 'og:locale' , content : site . lang } ] ,
166+ [ 'meta' , { property : 'og:title' , content : title } ]
167+ )
168+ }
169+ : undefined
170+ } )
0 commit comments