使用vuepress开发个人的博客

日报狂魔
• 阅读 3586

https://vuepress.vuejs.org/zh/

话不多说先贴一张图👀

使用vuepress开发个人的博客

使用vuepress开发个人的博客

开发这样的一个博客发布在github.io上很简单,下面就开始吧!

  1. 开始安装项目
# 将 VuePress 作为一个本地依赖安装
yarn add -D vuepress # 或者:npm install -D vuepress

# 新建一个 docs 文件夹
mkdir docs

# 新建一个 markdown 文件
echo '# Hello VuePress!' > docs/README.md

# 开始写作
npx vuepress dev docs
  1. 配置package.json
{
  "scripts": {
    "docs:dev": "vuepress dev docs",
    "docs:build": "vuepress build docs"
  }
}

配置

  • 项目文件目录
.
├─ docs
│  ├─ README.md
│  └─ .vuepress
|     ├─components // 自定义组件
      ├─override.styl // 覆盖样式
│     └─ config.js // 配置文件
└─ package.json
  • 页面配置
module.exports = {
  title: 'Hello VuePress',
  description: 'Just playing around'
}

主要是config.js中的配置

const path = require('path');
const fs = require('fs');
module.exports = {
  title: 'BLOG',
  description: 'Curriculum Vitae',
  markdown: {
    lineNumbers: true
  },
  themeConfig: {
    nav: [
      { text: '首页', link: '/' },
      { text: '技术', link: '/learning-notes/' },
      { text: '读书', link: '/reading/' },
      { text: '面试题', link: '/interview/' },
      { text: '关于', link: '/about/' },
      { text: 'github', link: 'https://github.com/zhaotbj' }
    ],
    sidebar: {
      '/learning-notes/': [
        {
          title: "Node.js",
          collapsable: true,
          children: genSidebarConfig("learning-notes/node", true)
        },
        {
          title: "Vue",
          collapsable: true,
          children: genSidebarConfig("learning-notes/vue", true)
        },
        {
          title: "React",
          collapsable: true,
          children: genSidebarConfig("learning-notes/react", true)
        },
         {
          title: "JS",
          collapsable: true,
          children: genSidebarConfig("learning-notes/js", true)
        },
        {
          title: "微信小程序",
          collapsable: true,
          children: []
        }
      ],
      '/interview/': [
        {
          title: "Vue面试题",
          collapsable: true,
          children: genSidebarConfig("interview/vue", true)
        },
        {
          title: "慕课网前端跳槽面试必备技巧",
          collapsable: true,
          children: genSidebarConfig("interview/muke", true)
        },
      ],
      '/reading/': [
        {
          title: "读书笔记",
          collapsable: true,
          children: genSidebarConfig("reading/reading-notes", true)
        }
      ]
    }

  }
}

function genSidebarConfig(dir, hasSub) {
  let p = path.join(__dirname, '../', dir);
  let files = fs.readdirSync(p);
  let subDir = hasSub ? dir.split('/')[1] : '';
  files = files.map(item => {
    item = subDir ? subDir + '/' + path.basename(item, '.md') : path.basename(item, '.md');
    return item;
  });
  return files;
}

部署上线

如果你打算发布到 https://<USERNAME>.github.io/

首先在GitHub建立一个仓库

使用vuepress开发个人的博客

  • 项目运行命令打包
// 生成静态文件
npm run docs:build

// 进入生成的文件夹
cd docs/.vuepress/dist
git init
git add -A
git commit -m 'deploy'


// 如果发布到 https://<USERNAME>.github.io

git remote add origin git@github.com:zhaotbj.github.io.git

git push -f git@github.com:zhaotbj/zhaotbj.github.io.git

// or git push -f git@github.com:zhaotbj/zhaotbj.github.io.git master


// 访问
https://zhaotbj.github.io

恭喜你,运行到这里就可以访问啦! https://zhaotbj.github.io

GitHub地址 https://github.com/zhaotbj/vu...

如果喜欢,给个赞啦🙏~

欢迎加入大前端学习交流群
😎🔥🔥🔥

使用vuepress开发个人的博客

点赞
收藏
评论区
推荐文章
美凌格栋栋酱 美凌格栋栋酱
8个月前
Oracle 分组与拼接字符串同时使用
SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
冴羽 冴羽
3年前
VuePress 博客优化之开启 HTTPS
前言在中,我们使用VuePress搭建了一个博客,最终的效果查看:。注意此时,我们的域名还是,众所周知,开启HTTPS有很多好处,比如可以实现数据加密传输等,那我们如何开启HTTPS配置呢?1.购买证书阿里云提供了免费证书可以使用,在每个自然年内,都可以通过SSL证书服务一次性申领20张免费证书。1.1购买证书访问,选择「D
冴羽 冴羽
3年前
VuePress 博客如何开启本地 HTTPS 访问
前言在中,我们使用VuePress搭建了一个博客,最终的效果查看:。如果我们在本地运行项目,运行地址类似于http://localhost:8080/learntypescript/,以http开头,这在大部分时候都满足了需要,但有的时候,比如兼容PWA,就需要以https开头,那我们如何在本地使用https地址呢?开启HTTPS在
Stella981 Stella981
3年前
Linux查看GPU信息和使用情况
1、Linux查看显卡信息:lspci|grepivga2、使用nvidiaGPU可以:lspci|grepinvidia!(https://oscimg.oschina.net/oscnet/36e7c7382fa9fe49068e7e5f8825bc67a17.png)前边的序号"00:0f.0"是显卡的代
Wesley13 Wesley13
3年前
FLV文件格式
1.        FLV文件对齐方式FLV文件以大端对齐方式存放多字节整型。如存放数字无符号16位的数字300(0x012C),那么在FLV文件中存放的顺序是:|0x01|0x2C|。如果是无符号32位数字300(0x0000012C),那么在FLV文件中的存放顺序是:|0x00|0x00|0x00|0x01|0x2C。2.  
Stella981 Stella981
3年前
SpringBoot整合Redis乱码原因及解决方案
问题描述:springboot使用springdataredis存储数据时乱码rediskey/value出现\\xAC\\xED\\x00\\x05t\\x00\\x05问题分析:查看RedisTemplate类!(https://oscimg.oschina.net/oscnet/0a85565fa
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
3年前
PHP创建多级树型结构
<!lang:php<?php$areaarray(array('id'1,'pid'0,'name''中国'),array('id'5,'pid'0,'name''美国'),array('id'2,'pid'1,'name''吉林'),array('id'4,'pid'2,'n
Easter79 Easter79
3年前
SpringBoot整合Redis乱码原因及解决方案
问题描述:springboot使用springdataredis存储数据时乱码rediskey/value出现\\xAC\\xED\\x00\\x05t\\x00\\x05问题分析:查看RedisTemplate类!(https://oscimg.oschina.net/oscnet/0a85565fa