Skip to content

官网:https://vitepress.dev/zh/

一、环境

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 site

2、vitepress依赖

cd site
bun add -D vitepress

3、创建项目

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/