手把手带你用 VuePress + Github Pages 搭建博客

ea88c96f6ca28dc0c54ff58dd69d2a88.png

3. 添加导航栏


我们现在在页首的右上角添加导航栏,修改 config.js:

module.exports = {

title: ‘…’,

description: ‘…’,

themeConfig: {

nav: [

{ text: ‘首页’, link: ‘/’ },

{

text: ‘冴羽的 JavaScript 博客’,

items: [

{ text: ‘Github’, link: ‘https://github.com/mqyqingfeng’ },

{ text: ‘掘金’, link: ‘https://juejin.cn/user/712139234359182/posts’ }

]

}

]

}

}

效果如下:

e45570d5923f7ee58c55f5afd06b6606.png

更多的配置参考 VuePress 导航栏。

4. 添加侧边栏


现在我们添加一些 md 文档,目前文档的目录如下:

.

├─ docs

│  ├─ README.md

│  └─ .vuepress

│     └─ config.js

|  └─ handbook

|     └─ ConditionalTypes.md

|     └─ Generics.md

└─ package.json

我们在 config.js 配置如下:

module.exports = {

themeConfig: {

nav: […],

sidebar: [

{

title: ‘欢迎学习’,

path: ‘/’,

collapsable: false, // 不折叠

children: [

{ title: “学前必读”, path: “/” }

]

},

{

title: “基础学习”,

path: ‘/handbook/ConditionalTypes’,

collapsable: false, // 不折叠

children: [

{ title: “条件类型”, path: “/handbook/ConditionalTypes” },

{ title: “泛型”, path: “/handbook/Generics” }

],

}

]

}

}

对应的效果如下:

3bc012ee64b6daeed76ec86cf57071fa.png

5. 更换主题


现在基本的目录和导航功能已经实现,但如果我还想要加载 loading、切换动画、模式切换(暗黑模式)、返回顶部、评论等功能呢,为了简化开发成本,我们可以直接使用主题,这里使用的主题是 vuepress-theme-rec:

现在我们安装 vue

  • 28
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值