VuePress 配置记录

VuePress 配置记录

mkdir vuepress-starter && cd vuepress-starter
npm init
npm install -D vuepress
vim package.json
### 添加如下内容
{
  "scripts": {
    "docs:dev": "vuepress dev docs",
    "docs:build": "vuepress build docs",
    "docs:deploy": "bash deploy.sh"
  }
}
###

mkdir -p docs/public/assets
vim docs/README.md # 内容如下
vim docs/public/config.js # 内容如下
vim deploy.sh # 内容如下

npm run docs:dev

README.md

---
home: true
heroImage: /assets/avatar.jpg
heroText: NFE-W`S BLOG
tagline: Just a study note for myself
actionText: Go →
actionLink: /sui-bi/
features:
- title: 随笔
  details: 随便记记。
- title: Todo
  details: todo
- title: Todo
  details: todo
footer: MIT Licensed | Copyright © 2022-present NFE-W
---

config.js

module.exports = {
  title: 'NFE-W`S BLOG',
  description: 'Just a study note for myself',
  base: '/',
  markdown: {
    lineNumbers: true // 代码块显示行数
  },
  plugins: ['permalink-pinyin', ['autobar', {'pinyinNav': true}], 'rpurl'],
  themeConfig: {
    repo: 'https://github.com/nfe-w',
    repoLabel: 'GitHub',
    nav: [
      { text: 'Home', link: '/' },
      { text: 'Repo', link: 'https://github.com/nfe-w/my-note' },
    ],
  }
}

deploy.sh

#!/bin/sh

# 确保脚本抛出遇到的错误
set -e

npm run docs:build

cd docs/.vuepress/dist

# 如果是发布到自定义域名
echo 'note.nfe-w.top' > CNAME

git init
git add -A
git commit -m 'deploy'

# 如果发布到 https://<USERNAME>.github.io
# git push -f git@github.com:<USERNAME>/<USERNAME>.github.io.git master

# 如果发布到 https://<USERNAME>.github.io/<REPO>
# git push -f git@github.com:<USERNAME>/<REPO>.git master:gh-pages

git push -f git@github.com:nfe-w/nfe-w.github.io.git master

cd -

自动侧边栏插件

npm install -D boboidream/vuepress-bar
vim docs/public/config.js # 配置中添加插件,内容如下
module.exports = {
  plugins: ['autobar']
}

链接拼音插件

npm install -D vuepress-plugin-permalink-pinyin
vim docs/public/config.js # 配置中添加插件,内容如下
module.exports = {
	plugins: ['permalink-pinyin'] // 如果结合自动侧边插件,应为 plugins: ['permalink-pinyin', ['autobar', {'pinyinNav': true}]]
}

链接美化插件

npm install -D boboidream/vuepress-plugin-rpurl
vim docs/public/config.js # 配置中添加插件,内容如下
module.exports = {
	plugins: ['rpurl']
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值