# vuepress生成静态html网页
当前还不会如何使用这个vuepress,首页暂时空着
# 创建vuepress项目
vue create my-project
my-project 就是一个新的项目名,可以根据自己的需要修改。
进入到 my-project 文件夹中,安装 Vue 的静态网站生成工具(Vuepress)。安装命令为:
npm install -D vuepress
如果下载不下来包,设置npm镜像源为淘宝镜像: https://registry.npmmirror.com/
npm set registry https://registry.npmmirror.com/
创建一个 markdown 文件(例如 index.md),并在文件中编写页面内容。
创建一个 .vuepress 文件夹,并在其中创建 config.js 文件。config.js 中的内容如下:
module.exports = {
title: 'My Site', // 网站的标题
description: 'This is my site', // 网站的描述
themeConfig: { // 主题配置
nav: [
{ text: 'Home', link: '/' },
{ text: 'Guide', link: '/guide/' },
{ text: 'External', link: 'https://google.com' },
],
sidebar: [
'/',
'/guide/',
]
}
}
其中,nav 和 sidebar 是主题页面导航的配置,可以根据自己的需要进行修改。
通过以下命令在本地启动网站,查看生成的静态 html 文件:
npx vuepress dev
执行以下命令构建生成静态 html 文件:
npx vuepress build
之后静态 html 文件就会生成在 .vuepress/dist 目录下了。将这个目录下的文件上传到服务器上即可。
# vuepress打包
Vue 报错error:0308010C:digital envelope routines::unsupported
出现这个错误是因为 node.js V17版本中最近发布的OpenSSL3.0, 而OpenSSL3.0对允许算法和密钥大小增加了严格的限制,可能会对生态系统造成一些影响.
打开终端(按健win+R弹出窗口,键盘输入cmd,然后敲回车)并按照说明粘贴这些:(不一定行,本人失败了)
Linux & Mac OS (windows git bash)
export NODE_OPTIONS=--openssl-legacy-provider
windows命令提示符:
set NODE_OPTIONS=--openssl-legacy-provider