接上一节:VitePress搭建博客教程系列(2) – VitePress默认首页和头部导航配置
关于默认主题相关细节配置,我们也是通过配置文件config.js中的themeConfig选项来配置的,以下所有配置都是在themeConfig中完成的
1、修改顶部网站的logo和标题
默认情况下,网站的logo会引用 配置的站点标题。如果想修改网站的logo标题,则可以在 themeConfig.siteTitle 选项中设置定义标题。
export default {
themeConfig: {
siteTitle: '前端吧qianduan8.com'
}
}
上面是纯文本的logo文字,如果想修改为图片来展示网站的logo,则可以通过如下设置
export default {
themeConfig: {
// 导航上的logo
logo: "/logo.png",
// 隐藏logo右边的标题
siteTitle: false,
}
}
// 主题配置
themeConfig: {
// 编辑链接
editLink: {
pattern: "https://github.com/vuejs/vitepress/edit/main/docs/:path", // 自己项目仓库地址
text: "在 github 上编辑此页",
},
},

// 站点页脚配置
footer: {
message: "Released under the MIT License",
copyright: "Copyright © 2023-present Lao Yuan",
},
socialLinks: [
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' },
// 也可以自定义svg的icon:
{
icon: {
svg: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Dribbble</title><path d="M12...6.38z"/></svg>'
},
link: '...'
}
]
默认就已经是如下配置了:

想要修改如下设置即可
// 右侧边栏配置,默认值是"In hac pagina" outlineTitle: "本页目录",

最后更新时间需要在 themeConfig 平级去开启此选项,然后在 themeConfig 中可以去定制其展示文字。需要注意的是配置之后不会立即生效,需要git提交发布服务器之后可以生效,如下:
// 获取每个文件最后一次 git 提交的 UNIX 时间戳(ms),同时它将以合适的日期格式显示在每一页的底部
lastUpdated: true, // string | boolean
// 主题配置
themeConfig: {
lastUpdatedText: "最后更新", // string
}
https://docsearch.algolia.com/apply
// 搜索
algolia: {
apiKey: "your_api_key",
indexName: "index_name",
},

