从零用VitePress搭建博客教程(3) - VitePress页脚、标题logo、最后更新时间等相关细节配置
接上一节:从零用VitePress搭建博客教程(2) –VitePress默认首页和头部导航、左侧导航配置
五、默认主题相关细节配置
关于默认主题的标题,logo、页脚,最后更新时间等相关细节配置,我们也是通过文件config.js中的themeConfig选项配置的,以下所有配置都是在themeConfig中完成的
1、修改顶部网站的logo和标题
默认情况下,网站的logo会引用 config.title 配置的站点标题。如果想修改网站的logo标题,则可以在 themeConfig.siteTitle 选项中设置定义标题。
1 2 3 4 5 | export default { themeConfig: { siteTitle: '前端吧qianduan8.com' } } |
上面是纯文本的logo文字,如果想修改为图片来展示网站的logo,则可以通过如下设置
1 2 3 4 5 6 7 8 | export default { themeConfig: { // 导航上的logo logo: "/logo.png" , // 隐藏logo右边的标题 siteTitle: false , } } |
1 2 3 4 5 6 7 8 | // 主题配置 themeConfig: { // 编辑链接 editLink: { pattern: "https://github.com/vuejs/vitepress/edit/main/docs/:path" , // 自己项目仓库地址 text: "在 github 上编辑此页" , }, }, |
1 2 3 4 5 | // 站点页脚配置 footer: { message: "Released under the MIT License" , copyright: "Copyright © 2023-present Lao Yuan" , }, |
1 2 3 4 5 6 7 8 9 10 | 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: '...' } ] |
默认就已经是如下配置了:
想要修改如下设置即可
1 2 | // 右侧边栏配置,默认值是"In hac pagina" outlineTitle: "本页目录" , |
最后更新时间需要在 themeConfig 平级去开启此选项,然后在 themeConfig 中可以去定制其展示文字。需要注意的是配置之后不会立即生效,需要git提交发布服务器之后可以生效,如下:
1 2 3 4 5 6 | // 获取每个文件最后一次 git 提交的 UNIX 时间戳(ms),同时它将以合适的日期格式显示在每一页的底部 lastUpdated: true , // string | boolean // 主题配置 themeConfig: { lastUpdatedText: "最后更新" , // string } |
1 2 3 4 5 | // 搜索 algolia: { apiKey: "your_api_key" , indexName: "index_name" , }, |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构