Skip to content

Commit 1b938fd

Browse files
author
胡小龙
committed
配置 GitHub Pages 博客
0 parents  commit 1b938fd

36 files changed

Lines changed: 7107 additions & 0 deletions

.gitattributes

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
* text eol=lf
2+
*.txt text eol=crlf
3+
4+
*.png binary
5+
*.jpg binary
6+
*.jpeg binary
7+
*.ico binary
8+
*.tff binary
9+
*.woff binary
10+
*.woff2 binary

.github/workflows/deploy.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: deploy
2+
3+
on:
4+
# 每当 push 到 main 分支时触发部署
5+
# Deployment is triggered whenever a push is made to the main branch.
6+
push:
7+
branches: [main]
8+
# 手动触发部署
9+
# Manually trigger deployment
10+
workflow_dispatch:
11+
12+
jobs:
13+
docs:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
20+
# "Last updated time" and other git log-related information require fetching all commit records.
21+
fetch-depth: 0
22+
23+
- name: Setup pnpm
24+
uses: pnpm/action-setup@v4
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
# 选择要使用的 node 版本
30+
node-version: 22
31+
32+
33+
# 安装依赖
34+
# Install dependencies
35+
- name: Install Dependencies
36+
run: pnpm install --frozen-lockfile
37+
38+
39+
# 运行构建脚本
40+
# Run the build script
41+
- name: Build VuePress site
42+
run: pnpm run docs:build
43+
44+
45+
# 查看 workflow 的文档来获取更多信息
46+
# @see https://github.com/crazy-max/ghaction-github-pages
47+
- name: Deploy to GitHub Pages
48+
uses: crazy-max/ghaction-github-pages@v4
49+
with:
50+
# 部署到 gh-pages 分支
51+
target_branch: gh-pages
52+
# 部署目录为 VuePress 的默认输出目录
53+
build_dir: docs/.vuepress/dist
54+
env:
55+
# @see https://docs.github.com/cn/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/docs-deploy.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Deploy Docs
2+
3+
on:
4+
# 每当 push 到 main 分支时触发部署
5+
push:
6+
branches: [main]
7+
# 手动触发部署
8+
workflow_dispatch:
9+
10+
jobs:
11+
docs:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
# "最近更新时间" 等 git 日志相关信息,需要拉取全部提交记录
18+
fetch-depth: 0
19+
20+
- name: Setup pnpm
21+
uses: pnpm/action-setup@v4
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
# 选择要使用的 node 版本
27+
node-version: 22
28+
cache: pnpm
29+
30+
# 安装依赖
31+
- name: Install Dependencies
32+
run: pnpm install --frozen-lockfile
33+
34+
# 运行构建脚本
35+
- name: Build VuePress site
36+
run: pnpm run docs:build
37+
38+
# 部署到 GitHub Pages
39+
- name: Deploy to GitHub Pages
40+
uses: crazy-max/ghaction-github-pages@v4
41+
with:
42+
# 部署到 gh-pages 分支
43+
target_branch: gh-pages
44+
# 部署目录为 VuePress 的默认输出目录
45+
build_dir: docs/.vuepress/dist
46+
env:
47+
# @see https://docs.github.com/cn/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
**/node_modules
2+
3+
docs/.vuepress/.cache
4+
docs/.vuepress/.temp
5+
docs/.vuepress/dist
6+
7+
.DS_Store
8+
*.log

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
shamefully-hoist=true
2+
shell-emulator=true

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# my-blog
2+
3+
The Site is generated using [vuepress](https://vuepress.vuejs.org/) and [vuepress-theme-plume](https://github.com/pengzhanbo/vuepress-theme-plume)
4+
5+
## Install
6+
7+
```sh
8+
pnpm i
9+
```
10+
11+
## Usage
12+
13+
```sh
14+
# start dev server
15+
pnpm docs:dev
16+
# build for production
17+
pnpm docs:build
18+
# preview production build in local
19+
pnpm docs:preview
20+
# update vuepress and theme
21+
pnpm vp-update
22+
```
23+
24+
## Deploy to GitHub Pages
25+
26+
The plume theme has been created with GitHub Actions: `.github/workflows/docs-deploy.yml`. You also need to make the following settings in the GitHub repository:
27+
28+
- [ ] `settings > Actions > General`, Scroll to the bottom of the page, under `Workflow permissions`, check `Read and write permissions`, and click the save button.
29+
30+
- [ ] `settings > Pages`, In `Build and deployment`, select `Deploy from a branch` for `Source`, choose `gh-pages` for `Branch`, and click the save button.
31+
(The `gh-pages` branch may not exist upon first creation. You can complete the above setup first, push the code to the main branch, wait for `github actions` to finish, and then proceed with the setup.)
32+
33+
- [ ] Modify the `base` option in `docs/.vuepress/config.ts`:
34+
- If you are planning to deploy to `https://<USERNAME>.github.io/`, you can skip this step as `base` defaults to `"/"`.
35+
- If you are planning to deploy to `https://<USERNAME>.github.io/<REPO>/`, meaning your repository URL is `https://github.com/<USERNAME>/<REPO>`, set `base` to `"/<REPO>/"`.
36+
37+
To customize a domain name, please refer to [Github Pages](https://docs.github.com/zh/pages/configuring-a-custom-domain-for-your-github-pages-site/about-custom-domains-and-github-pages)
38+
39+
## Documents
40+
41+
- [vuepress](https://vuepress.vuejs.org/)
42+
- [vuepress-theme-plume](https://theme-plume.vuejs.press/)

README.zh-CN.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# my-blog
2+
3+
网站使用 [vuepress](https://vuepress.vuejs.org/)[vuepress-theme-plume](https://github.com/pengzhanbo/vuepress-theme-plume) 构建生成。
4+
5+
## Install
6+
7+
```sh
8+
pnpm i
9+
```
10+
11+
## Usage
12+
13+
```sh
14+
# 启动开发服务
15+
pnpm docs:dev
16+
# 构建生产包
17+
pnpm docs:build
18+
# 本地预览生产服务
19+
pnpm docs:preview
20+
# 更新 vuepress 和主题
21+
pnpm vp-update
22+
```
23+
24+
## 部署到 GitHub Pages
25+
26+
主题已创建 github actions: `.github/workflows/docs-deploy.yml`,你还需要在 github 仓库中进行以下设置:
27+
28+
- [ ] `settings > Actions > General`,拉到页面底部,在 `Workflow permissions` 下,勾选 `Read and write permissions`,并点击保存按钮
29+
30+
- [ ] `settings > Pages`, 在 `Build and deployment` 中,`Source` 选择 `Deploy from a branch`, `Branch` 选择 `gh-pages`,并点击保存按钮
31+
(首次创建可能没有 `gh-pages`分支,你可以先完成上面的设置后,推送一次代码到主分支,等待 `github actions` 完成后再进行设置)
32+
33+
- [ ] 修改 `docs/.vuepress/config.ts` 中的 `base` 选项:
34+
- 如果你准备发布到 `https://<USERNAME>.github.io/` ,你可以省略这一步,因为 `base` 默认就是 `"/"`
35+
- 如果你准备发布到 `https://<USERNAME>.github.io/<REPO>/` ,也就是说你的仓库地址是 `https://github.com/<USERNAME>/<REPO>` ,则将 `base` 设置为 `"/<REPO>/"`
36+
37+
如需要自定义域名,请查看 [Github Pages 文档](https://docs.github.com/zh/pages/configuring-a-custom-domain-for-your-github-pages-site/about-custom-domains-and-github-pages)
38+
39+
## 文档
40+
41+
- [vuepress](https://vuepress.vuejs.org/)
42+
- [vuepress-theme-plume](https://theme-plume.vuejs.press/)

docs/.vuepress/client.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { defineClientConfig } from 'vuepress/client'
2+
// import RepoCard from 'vuepress-theme-plume/features/RepoCard.vue'
3+
// import NpmBadge from 'vuepress-theme-plume/features/NpmBadge.vue'
4+
// import NpmBadgeGroup from 'vuepress-theme-plume/features/NpmBadgeGroup.vue'
5+
// import Swiper from 'vuepress-theme-plume/features/Swiper.vue'
6+
7+
// import CustomComponent from './theme/components/Custom.vue'
8+
9+
// import './theme/styles/custom.css'
10+
11+
export default defineClientConfig({
12+
enhance({ app }) {
13+
// built-in components
14+
// app.component('RepoCard', RepoCard)
15+
// app.component('NpmBadge', NpmBadge)
16+
// app.component('NpmBadgeGroup', NpmBadgeGroup)
17+
// app.component('Swiper', Swiper) // you should install `swiper`
18+
19+
// your custom components
20+
// app.component('CustomComponent', CustomComponent)
21+
},
22+
})

0 commit comments

Comments
 (0)