vuepresscss
# 安装 yarn global add vuepress # 或者:npm install -g vuepress # 新建一个 markdown 文件 echo '# Hello VuePress!' > README.md # 开始写做 vuepress dev . # 构建静态文件 vuepress build .
接着,在 package.json
里加一些脚本:html
{ "scripts": { "docs:dev": "vuepress dev docs", "docs:build": "vuepress build docs" } }
yarn docs:dev # 或者:npm run docs:dev
固然这对于大多数人来讲都是很简单的问题,自vuepress公开之后,有太多筒子想要vuepress添加评论系统,但是目测大佬们并无这个想法,不过对于vue.js生态环境而言,给咱们不少本身动手的可能。下面请食用个人开发方法。vue
前二者都是有厚实的长城,因此我建议各位就别想了,虽然有搭建过的blog。若是有想了解的请看VuePress 集成第三方评论模块。git
我选择了Valine,请你们看。github
看到上面是否是以为挺好看...接下来开发
<template> <div class="vcomment" v-if="data.comments === true"> <div id="vcomments"></div> </div> </template>
<script> import { isActive, hashRE, groupHeaders } from '../util' export default { computed: { data () { return this.$page.frontmatter }, }, mounted: function(){ this.createValine() }, methods: { createValine() { const Valine = require('valine'); window.AV = require('leancloud-storage') const valine = new Valine({ el: '#vcomments', appId: '', appKey: '', notify: false, verify: false, avatar: 'monsterid', path: window.location.pathname, placeholder: '欢迎留言与我分享您的想法...', }); this.valineRefresh = false } }, watch: { '$route' (to, from) { if(to.path !== from.path){ setTimeout(() => { //从新刷新valine this.createValine() }, 300) } /** * TODO: * 1. 使用其余方法更新评论组件 或者使用其余较为好用的评论组件 * 2. 添加categories and tag * 3. 更换其余主题 */ } } } </script>
<style lang="stylus" rel="stylesheet/stylus"> #vcomments { max-width 740px padding 10px display block; margin-left auto; margin-right auto; } </style>
加入以上代码便可完成真个评论系统,而后
yarn dev
便可看到效果!
vuepress-blog 欢迎star!mmmjson
个人blog微信