@@ -2,22 +2,22 @@ import {
22 defaultHoverInfoProcessor ,
33 transformerTwoslash ,
44} from "@shikijs/vitepress-twoslash" ;
5- import {
6- groupIconMdPlugin ,
7- groupIconVitePlugin ,
8- } from "vitepress-plugin-group-icons" ;
95import { defineConfig } from "vitepress" ;
10- // import { ar, arSearch } from "./ar.mts";
11- import { en , enSearch } from "./en.mts" ;
6+ import { groupIconMdPlugin } from "vitepress-plugin-group-icons" ;
127// import { es, esSearch } from "./es.mts";
8+ import { getAllLocaleConfig , i18n , rootLang } from "./i18n.mts" ;
139import vite from "./vite.config.mts" ;
14- import { zh , zhSearch } from "./zh.mts" ;
1510
16- const js = String . raw ;
11+ const all = getAllLocaleConfig ( ) ;
12+
13+ /**
14+ * 开发模式下,默认禁用搜索能力,如果有需要,手动开启
15+ */
16+ const enableSearch = process . env . npm_lifecycle_event === "build" ;
17+
1718// https://vitepress.dev/reference/site-config
1819export default defineConfig ( {
1920 title : "DwebBrowser" ,
20- description : "一个提供分布式网络 | 应用附着的浏览器。" ,
2121 lastUpdated : true ,
2222 cleanUrls : false ,
2323 markdown : {
@@ -39,17 +39,16 @@ export default defineConfig({
3939 } ,
4040 // errorRendering: 'hover',
4141 processHoverInfo ( info ) {
42- return defaultHoverInfoProcessor ( info )
43- // Remove shiki_core namespace
44- . replace ( / _ s h i k i j s _ c o r e \w * \. / g, "" ) ;
42+ return (
43+ defaultHoverInfoProcessor ( info )
44+ // Remove shiki_core namespace
45+ . replace ( / _ s h i k i j s _ c o r e \w * \. / g, "" )
46+ ) ;
4547 } ,
4648 } ) ,
47- ] ,
49+ ] as any ,
4850 } ,
49- head : [
50- [ "link" , { rel : "icon" , type : "image/svg+xml" , href : "/logo.svg" } ] ,
51- [ "link" , { rel : "icon" , type : "image/png" , href : "/logo.png" } ] ,
52- ] ,
51+ head : [ [ "link" , { rel : "icon" , type : "image/svg+xml" , href : "/logo.svg" } ] ] ,
5352 themeConfig : {
5453 logo : "/logo.svg" ,
5554
@@ -60,20 +59,23 @@ export default defineConfig({
6059 } ,
6160 ] ,
6261
63- search : {
64- provider : "local" ,
65- options : {
66- locales : { ...zhSearch , ...enSearch } , // ...arSearch, ...esSearch
67- } ,
68- } ,
69- } ,
70- locales : {
71- root : { label : "简体中文" , ...zh } ,
72- en : { label : "English" , ...en } ,
73- // es: { label: "Spanish", ...es },
74- // ar: { label: "Arabic", ...ar },
62+ search : enableSearch
63+ ? {
64+ provider : "local" ,
65+ options : {
66+ locales : Object . keys ( all ) . reduce ( ( locales , key ) => {
67+ locales [ key === rootLang ? "root" : key ] = all [ key ] . search ;
68+ return locales ;
69+ } , { } ) ,
70+ } ,
71+ }
72+ : undefined ,
7573 } ,
76- vite,
74+ locales : Object . keys ( all ) . reduce ( ( locales , key ) => {
75+ locales [ key === rootLang ? "root" : key ] = i18n ( key , all [ key ] ) ;
76+ return locales ;
77+ } , { } ) ,
78+ vite : vite as any ,
7779 vue : {
7880 template : {
7981 compilerOptions : {
0 commit comments