mirror of
https://github.com/handsomezhuzhu/handsomezhuzhu.github.io.git
synced 2026-02-20 20:00:14 +00:00
主体更新以及readme文件修改
This commit is contained in:
78
README.md
78
README.md
@@ -1,69 +1,97 @@
|
|||||||
<h1 align="center"> VitePress @sugarat/theme </h1>
|
# 我的个人博客
|
||||||
|
|
||||||
<p align="center">
|
本项目基于 [VitePress](https://vitepress.dev/) 构建,并使用了 [@sugarat/theme](https://theme.sugarat.top/) 主题。
|
||||||
简约风的 <a href="https://theme.sugarat.top" target="_blank"target="_blank">VitePress 博客主题</a> 示例运行项目。
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p align="center">
|
## 安装与启动
|
||||||
<a href="https://atqq.github.io/vitepress-blog-sugar-template/" target="_blank">GitHub Pages Demo</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
## Usage
|
**1. 环境准备**
|
||||||
|
|
||||||
先安装 `pnpm`
|
请确保你的环境中已经安装了 [Node.js](https://nodejs.org/en/) (版本 >= 18) 和 [pnpm](https://pnpm.io/installation)。
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
# 安装 pnpm
|
||||||
npm i -g pnpm
|
npm i -g pnpm
|
||||||
```
|
```
|
||||||
|
|
||||||
安装依赖
|
**2. 安装依赖**
|
||||||
|
|
||||||
|
你可以使用 `pnpm` 或者 `bun` 来安装项目依赖。
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
# 使用 pnpm
|
||||||
pnpm install
|
pnpm install
|
||||||
|
|
||||||
|
# 或者使用 bun
|
||||||
|
bun install
|
||||||
```
|
```
|
||||||
|
|
||||||
开发启动
|
**3. 本地开发**
|
||||||
|
|
||||||
|
执行以下命令启动本地开发服务器:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pnpm dev
|
pnpm dev
|
||||||
```
|
```
|
||||||
|
|
||||||
构建
|
**4. 项目构建**
|
||||||
|
|
||||||
|
构建用于生产环境的静态文件:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pnpm build
|
pnpm build
|
||||||
```
|
```
|
||||||
|
|
||||||
预览产物
|
**5. 本地预览**
|
||||||
|
|
||||||
|
在本地预览构建后的产物:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pnpm serve
|
pnpm serve
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 主题与更新
|
||||||
|
|
||||||
|
### 更新主题
|
||||||
|
|
||||||
|
本项目使用 `@sugarat/theme` 主题,要升级到最新版本,请执行:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm add @sugarat/theme@latest
|
||||||
|
```
|
||||||
|
|
||||||
|
### 更新 VitePress
|
||||||
|
|
||||||
|
通常,主题包会依赖最新的 VitePress 版本。如果你需要手动更新 VitePress,可以执行:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm add vitepress@latest
|
||||||
|
```
|
||||||
|
|
||||||
## Github Pages 部署
|
## Github Pages 部署
|
||||||
|
|
||||||
① Github Pages 开启 Git Actions 部署支持
|
① 开启 Github Pages 的 Git Actions 部署支持。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
② 复制文件 `.github/workflows/deploy.yml` 到自己的项目相同目录下
|
② 复制 `.github/workflows/deploy.yml` 文件到你的项目相同目录下(如果已有则忽略)。
|
||||||
|
|
||||||
示例项目已包含,可以直接进行下一步
|
③ 修改 `docs/.vitepress/config.mts` 里的构建配置 `base`。
|
||||||
|
|
||||||
③ 修改 `docs/.vitepress/config.mts` 里的构建配置
|
**如果你的仓库名是 `username.github.io`,则不需要修改 `base`,保持默认值 `/` 即可。**
|
||||||
|
|
||||||
**如果项目名已经为 name.github.io 域名,则不需要修改,保持默认值 `/` 即可**
|
否则,需要将 `base` 修改为 `"/仓库名/"`。
|
||||||
|
|
||||||
`base` 改为 `"/仓库名/"` 即可
|
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
// 省略无关代码
|
// docs/.vitepress/config.mts
|
||||||
const base = '/vitepress-blog-sugar-template/'
|
import { defineConfig } from 'vitepress'
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
base,
|
// ... 其他配置
|
||||||
|
base: '/你的仓库名/',
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
④ 推送 `main` 分支即可
|
④ 推送代码到 `main` 分支即可触发自动部署。
|
||||||
|
|
||||||
|
如果需要进一步修改部署和构建配置,请直接编辑 `.github/workflows/deploy.yml` 文件。
|
||||||
|
|
||||||
需要进一步修改部署和构建配置,详见`deploy.yml` 文件。
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
"pagefind": "^1.3.0",
|
"pagefind": "^1.3.0",
|
||||||
"sass": "^1.76.0",
|
"sass": "^1.76.0",
|
||||||
"typescript": "^5.4.5",
|
"typescript": "^5.4.5",
|
||||||
"vitepress": "1.6.3"
|
"vitepress": "1.6.4"
|
||||||
},
|
},
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"peerDependencyRules": {
|
"peerDependencyRules": {
|
||||||
|
|||||||
3613
pnpm-lock.yaml
generated
Normal file
3613
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user