.
├─ /
│ ├─ .vitepress
│ │ └─ config.mts <-- 配置文件已由ts变成mts
│ ├─ api-examples.md <-- 文章1
│ ├─ markdown-examples.md <-- 文章2
│ └─ index.md <-- 首页
└─ package.json
在默认情况下Vitepress的链接结尾 .html
,如果你喜欢纯净的网址不使用 .html
我们需要变更下目录,将原先的文档使用文件夹,然后再文件夹内新建页面
.
├─ /
│ ├─ .vitepress
│ │ └─ config.mts <-- 配置文件已由ts变成mts
│ ├─ api-examples
│ │ └─ index.md <-- 文章1
│ ├─ markdown-examples
│ │ └─ index.md <-- 文章2
│ └─ index.md <-- 首页
└─ package.json
可以直接配置
export default defineConfig({
cleanUrls:true,
})
默认是浅色模式,可自行开启或更换
export default defineConfig({
//appearance:true, //默认浅色且开启切换
//启用深色模式
appearance:'dark',
})
要启用多语言支持,首先需要使用如下的文件目录结构。新建一个语言目录,再把根目录所有文档,翻译后再放进去。默认读取目录的index文件,无需手动填写 index
.
├─ /
│ ├─ en
│ │ ├─ index.md <--英文首页
│ │ ├─ ...
│ │ ...
│ └─ fr
│ │ ├─ index.md <--法语首页
│ │ ├─ ...
│ │ ...
│ └─ index.md <--中文首页(默认)
└─ package.json
export default defineConfig({
//多语言
locales: {
root: {
label: '简体中文',
lang: 'Zh_CN',
},
en: {
label: 'English',
lang: 'en',
link: '/en/',
},
fr: {
label: 'French',
lang: 'fr',
link: '/fr/',
}
},
})
支持SVG
export default defineConfig({
themeConfig: {
//社交链接
socialLinks: [
{ icon: 'github', link: '<https://github.com/vuejs/vitepress>' },
{ icon: 'twitter', link: '<https://twitter.com/>' },
{ icon: 'discord', link: '<https://chat.vitejs.dev/>' },
{
icon: {
svg: '<svg t="1703483542872" class="icon" viewBox="0 0 1309 1024" version="1.1" xmlns="<http://www.w3.org/2000/svg>" p-id="6274" width="200" height="200"><path d="M1147.26896 912.681417l34.90165 111.318583-127.165111-66.823891a604.787313 604.787313 0 0 1-139.082747 22.263717c-220.607239 0-394.296969-144.615936-394.296969-322.758409s173.526026-322.889372 394.296969-322.889372C1124.219465 333.661082 1309.630388 478.669907 1309.630388 656.550454c0 100.284947-69.344929 189.143369-162.361428 256.130963zM788.070086 511.869037a49.11114 49.11114 0 0 0-46.360916 44.494692 48.783732 48.783732 0 0 0 46.360916 44.494693 52.090549 52.090549 0 0 0 57.983885-44.494693 52.385216 52.385216 0 0 0-57.983885-44.494692z m254.985036 0a48.881954 48.881954 0 0 0-46.09899 44.494692 48.620028 48.620028 0 0 0 46.09899 44.494693 52.385216 52.385216 0 0 0 57.983886-44.494693 52.58166 52.58166 0 0 0-57.951145-44.494692z m-550.568615 150.018161a318.567592 318.567592 0 0 0 14.307712 93.212943c-14.307712 1.080445-28.746387 1.768001-43.283284 1.768001a827.293516 827.293516 0 0 1-162.394168-22.296458l-162.001279 77.955749 46.328175-133.811485C69.410411 600.858422 0 500.507993 0 378.38496 0 166.683208 208.689602 0 463.510935 0c227.908428 0 427.594322 133.18941 467.701752 312.379588a427.463358 427.463358 0 0 0-44.625655-2.619261c-220.24709 0-394.100524 157.74498-394.100525 352.126871zM312.90344 189.143369a64.270111 64.270111 0 0 0-69.803299 55.659291 64.532037 64.532037 0 0 0 69.803299 55.659292 53.694846 53.694846 0 0 0 57.852923-55.659292 53.465661 53.465661 0 0 0-57.852923-55.659291z m324.428188 0a64.040926 64.040926 0 0 0-69.574114 55.659291 64.302852 64.302852 0 0 0 69.574114 55.659292 53.694846 53.694846 0 0 0 57.951145-55.659292 53.465661 53.465661 0 0 0-57.951145-55.659291z" p-id="6275"></path></svg>'
},
link: '<https://weixin.qq.com/>',
// You can include a custom label for accessibility too (optional but recommended):
ariaLabel: 'wechat'
}
],
},
})
vitepress自带的其他社交图标
/* node_modules\\vitepress\\types\\default-theme.d.ts */
export type SocialLinkIcon =
| 'discord'
| 'facebook'
| 'github'
| 'instagram'
| 'linkedin'
| 'mastodon'
| 'slack'
| 'twitter'
| 'x'
| 'youtube'
| { svg: string }