利用vuepress建立个人博客

建立博客

  • 在gitee中
npm install @vuepress-reco/theme-cli -g #插件安装
theme-cli init blogname #项目初始化
cd blogname 
cnpm install #安装依赖
  • gitee新建仓库,仓库名选择git账号名(这样就不用在config.js中修改base)
npm run dev // 本地运行
npm run build // 建立client端与server端
  • 将项目上传到gitee

  • 编写自动提交脚本

#!/bin/bash
git status
 
read -r -p "是否继续提交? [Y/n] " input

case $input in
    [yY][eE][sS]|[yY])
        echo "继续提交"
        git add -A
        git commit -m "shell提交"
        git push origin master
                    exit 1
        ;;

    [nN][oO]|[nN])
        echo "中断提交"
        exit 1
            ;;

    *)
    echo "输入错误,请重新输入"
    ;;
esac

常见问题整理:

解决system limit for number of file watchers reached 问题:

linux系统中限制了用户可以watch文件变更的最大数,因此需要通过sysctl.conf进行更改数值

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是一个简单的个人博客Vue2实现: 首先,在终端中使用以下命令创建一个新的Vue项目: ``` vue create my-blog ``` 然后,在项目目录中安装以下依赖项: ``` npm install --save vue-router marked highlight.js ``` 接下来,我们可以创建一个路由配置来管理不同的页面。在src目录下创建一个名为router.js的文件,并添加以下代码: ``` import Vue from 'vue' import Router from 'vue-router' import Home from './views/Home.vue' import Post from './views/Post.vue' Vue.use(Router) export default new Router({ routes: [ { path: '/', name: 'home', component: Home }, { path: '/post/:id', name: 'post', component: Post } ] }) ``` 这里我们定义了两个路由,一个是根路由指向Home组件,另一个是带有参数的路由指向Post组件。 接下来,我们可以创建两个组件分别用于显示博客主页和博客详情。在src/views目录下创建Home.vue和Post.vue文件,并添加以下代码: Home.vue ``` <template> <div class="home"> <h1>Welcome to my blog!</h1> <ul> <li v-for="post in posts" :key="post.id"> <router-link :to="'/post/' + post.id">{{ post.title }}</router-link> </li> </ul> </div> </template> <script> export default { data() { return { posts: [ { id: 1, title: 'My first blog post', content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.' }, { id: 2, title: 'My second blog post', content: 'Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.' }, { id: 3, title: 'My third blog post', content: 'At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores.' } ] } } } </script> ``` Post.vue ``` <template> <div class="post"> <h1>{{ post.title }}</h1> <div v-html="content"></div> </div> </template> <script> import marked from 'marked' import hljs from 'highlight.js' export default { data() { return { post: {} } }, created() { const postId = this.$route.params.id this.post = this.posts.find(post => post.id.toString() === postId) this.content = marked(this.post.content, { highlight: function(code, language) { if (language && hljs.getLanguage(language)) { return hljs.highlight(code, { language }).value } else { return hljs.highlightAuto(code).value } } }) }, computed: { posts() { return [ { id: 1, title: 'My first blog post', content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.' }, { id: 2, title: 'My second blog post', content: 'Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.' }, { id: 3, title: 'My third blog post', content: 'At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores.' } ] } } } </script> ``` 在Post.vue中,我们使用了marked和highlight.js来渲染markdown格式的博客文章内容。 最后,在App.vue中引入我们的路由和设置一个router-view用于渲染页面内容: ``` <template> <div id="app"> <router-view /> </div> </template> <script> import router from './router' export default { name: 'App', router } </script> ``` 现在,我们可以运行以下命令启动开发服务器: ``` npm run serve ``` 然后就可以在浏览器中访问http://localhost:8080来查看我们的博客网站了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值