vuepress 初体验:快速搭建博客

6/11/2020

# 基础配置

# 安装 node.js

请先安装Node.jsnpm,参考链接:廖雪峰的官方网站--JavaScript教程--安装Node.js和npm (opens new window)。或者直接下载安装当前(2020年7月)最新版本:Node v14.5.0 淘宝镜像 (opens new window),记得选择对应你的系统。

安装完成后,打开cmd,分别输入node -v,可以看到类似如下输出:

> node -v
v7.6.0
> npm -v
4.1.2

# 安装本地依赖

npm install -D vuepress

# UI插件配置

npm install -D @vuepress/plugin-back-to-top @vuepress/plugin-nprogress

安装完毕后,在config.js中配置

plugins:[
    ["@vuepress/back-top"],//返回页面顶部按钮
    ["@vuepress/nprogress"],//进度条
]

# PWA支持

npm install -D @vuepress/plugin-pwa

安装完毕后,在config.js中配置

module.exports = {
  head: [
    ['link', { rel: 'icon', href: '/logo.png' }],
    ['link', { rel: 'manifest', href: '/manifest.json' }],
    ['meta', { name: 'theme-color', content: '#3eaf7c' }],

  ],
  plugins: [
   ['@vuepress/pwa', {
    serviceWorker: true,
    updatePopup: true
  	}]
  ]
}
Home~in this corner~
Leina