项目地址:vuepress-theme-reform前端
效果展现: 个人博客vue
此主题继承至vuepress的默认主题,添加功能有标签页改造,主页改造,博客分类及展现,gitalk集成及gitalk自动化配置,最新google Analytics集成等。git
npm install vuepress-theme-reform -D # or yarn add vuepress-theme-reform
复制代码
而后在docs/.vuepress/config.js文件中添加github
{
...
theme:'reform'
...
}
复制代码
便可使用本主题npm
如需使用主页展现 在docs下的README.md中修改defaultHome:truejson
---
defaultHome: true
___
复制代码
在config.js中配置bash
...
nav: [
...
{
text: "博文",
icon: 'zhi',
items: [
{ text: "前端", link: "/blog/frontend/" }
]
}
...
]
复制代码
在docs/blog/frontend下新建README.md,在头部编写frontend
---
type: 'classify'
---
复制代码
那此文件夹下的其它文件都会被编译成展现的博文,此中的/blog/frontend自行定义 函数
在docs下新建tags,在tags下新建空的README.md网站
在config.js中的themeConfig下配置
...
themeConfig:{
...
tags:"tags"
...
nav:[
...
{
text: "标签云",
link: '/tags/',
tags: true
},
...
]
}
...
复制代码
其中后面的tags表示你标签云的文件夹名
在咱们写的文章中写
---
tags:
- vuepress
---
复制代码
就能在页面中看到效果
在config.js中配置
{
themConfig:{
...
gitalk: {
// gitalk的主要参数
clientID: `your clientID`,
clientSecret: `your clientSecret`,
repo: `your repo`,
owner: "yourname",
admin: ["yourname"],
accessToken: 'your accessToken ',
labelRule: `(title,path)=> { let paths=path.split('/') if(paths.length>0){ let res = paths.pop() if(res===''){ res=paths.pop() } res = res.slice(-50) return res }else{ return title } }`
},
...
}
}
复制代码
下载安装插件
yarn add vuepress-plugin-gitalk # npm i vuepress-plugin-gitalk -D
复制代码
在package.json中的scripts中加入
{
"scripts":{
...
"gitalk": "vuepress gitalk ./docs",
...
}
}
复制代码
执行
npm run gitalk
复制代码
便可输出自动化初始化评论的结果
vuepress提供了@vuepress/plugin-google-analytics,我使用事后没有效果,去google-analytics网站上发现当前的插入代码已有变化,因此本身内置了插件,只需在config.js中配置便可。
{
ga:'XXXX'
}
复制代码
若是自动化建立评论时输出
接口返回数据{"message":"Bad credentials","documentation_url":"https://developer.github.com/v3"}
xxx 建立失败
复制代码
报这个错误大几率是accessToken失效了,这时须要从新到github的Settings/Developer settings/Personal access tokens下建立获取并替换
效果展现: 个人博客