一、环境
1、硬件
树莓派
2、node.js
node.js需18 及以上版本,使用nvm安装:官网:https://nodejs.org/en/download/package-manager
[Prebuilt Installer] [Prebuilt Binaries] [Package Manager] [Source Code]
Install Node.js [v20.12.2(LTS)] on [Linux] using [NVM]
# installs NVM (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# download and install Node.js
nvm install 20
# verifies the right Node.js version is in the environment
node -v # should print `v20.12.2`
# verifies the right NPM version is in the environment
npm -v # should print `10.5.0`3、bun(替换npm,建议使用)
curl https://bun.sh/install | bash安装成功后会提示
bun was installed successfully to ~/.bun/bin/bun
Added "~/.bun/bin" to $PATH in "~/.bashrc"
To get started, run:
source /home/xxq/.bashrc
bun --help所以只需要执行 source ~/.bashrc
4、vscode
官网: https://code.visualstudio.com/#alt-downloads
安装vue扩展
二、vitepress
1、创建目录
mkdir site2、vitepress依赖
cd site
bun add -D vitepress3、创建项目
VitePress 附带一个命令行设置向导,可以帮助你构建一个基本项目。安装后,通过运行以下命令启动向导:
cd site
bun vitepress init将需要回答几个简单的问题:
┌ Welcome to VitePress!
│
◇ Where should VitePress initialize the config?
│ ./docs
│
◇ Site title:
│ My Awesome Project
│
◇ Site description:
│ A VitePress Site
│
◇ Theme:
│ ● Default Theme (Out of the box, good-looking docs)
│ ○ Default Theme + Customization
│ ○ Custom Theme
│
◇ Use TypeScript for config and theme files?
| Yes
│
◆ Add VitePress npm scripts to package.json?
| Yes
|
└ You're all set! Now run npx vitepress dev docs and start writing.4、测试
bun run docs:dev三、编译
bun run docs:build构建文档后,通过运行以下命令可以在本地预览它:
bun run docs:preview四、scp复制目录到阿里云服务器上
登录aliyun,删除dist目录下的文件
ssh root@xx.xx.xx.xx
cd /home/docker/nginx/html/dist
rm -rf *树莓派上操作,将当前dist目录复制到远程阿里云html目录下
scp -r /home/xxq/linux_share/site/docs/.vitepress/dist root@xx.xx.xx.xx:/home/docker/nginx/html/