Skip to content

Commit 7633932

Browse files
committed
add vuepress for github pages
1 parent 941566a commit 7633932

File tree

9 files changed

+4630
-4
lines changed

9 files changed

+4630
-4
lines changed

.github/workflows/deploy.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: 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@v2
22+
with:
23+
# 选择要使用的 pnpm 版本
24+
version: 8
25+
# 使用 pnpm 安装依赖
26+
run_install: true
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
# 选择要使用的 node 版本
32+
node-version: 20
33+
# 缓存 pnpm 依赖
34+
cache: pnpm
35+
36+
# 运行构建脚本
37+
- name: Build VuePress site
38+
run: pnpm docs:build
39+
40+
# 查看 workflow 的文档来获取更多信息
41+
# @see https://github.com/crazy-max/ghaction-github-pages
42+
- name: Deploy to GitHub Pages
43+
uses: crazy-max/ghaction-github-pages@v4
44+
with:
45+
# 部署到 gh-pages 分支
46+
target_branch: gh-pages
47+
# 部署目录为 VuePress 的默认输出目录
48+
build_dir: .vuepress/dist
49+
env:
50+
# @see https://docs.github.com/cn/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,9 @@
3030
*.exe
3131
*.out
3232
*.app
33+
34+
# vuepress
35+
node_modules/
36+
.vuepress/.cache/
37+
.vuepress/.temp/
38+
.vuepress/.dist/

.vuepress/config.js

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { viteBundler } from '@vuepress/bundler-vite';
2+
import { defineUserConfig } from 'vuepress';
3+
import { logoPath, repoBase, repoName, repoUrl } from './params';
4+
import { hopeTheme, mdEnhance } from 'vuepress-theme-hope';
5+
import { searchProPlugin } from 'vuepress-plugin-search-pro';
6+
7+
const tutorialPath = '/md/';
8+
const srcCodePath = tutorialPath + '详细分析/';
9+
10+
export default defineUserConfig({
11+
base: repoBase + '/',
12+
title: repoName,
13+
description: repoName,
14+
lang: 'zh-CN',
15+
theme: hopeTheme({
16+
sidebar: [
17+
{ text: '首页', link: '/', },
18+
{ text: '基本概念', link: tutorialPath + '01基本概念', },
19+
{ text: '使用线程', link: tutorialPath + '02使用线程', },
20+
{ text: '共享数据', link: tutorialPath + '03共享数据', },
21+
{ text: '同步操作', link: tutorialPath + '04同步操作', },
22+
{
23+
text: '详细分析', link: srcCodePath,
24+
collapsible: true,
25+
children: [
26+
{ text: 'std::thread 的构造-源码解析', link: srcCodePath + '01thread的构造与源码解析', },
27+
{ text: 'std::scoped_lock 的源码实现与解析', link: srcCodePath + '02scoped_lock源码解析', },
28+
{ text: 'std::async 与 std::future 源码解析', link: srcCodePath + '03async与future源码解析', },
29+
]
30+
},
31+
],
32+
favicon: logoPath,
33+
logo: logoPath,
34+
navTitle: repoName,
35+
repo: repoUrl,
36+
editLinkPattern: repoUrl + 'blob/main/:path',
37+
contributors: false,
38+
darkmode: 'toggle',
39+
pageInfo: ['ReadingTime'],
40+
}),
41+
plugins: [
42+
mdEnhance({
43+
footnote: true,
44+
imgLazyload: true
45+
}),
46+
searchProPlugin({
47+
indexContent: true,
48+
autoSuggestions: true
49+
})
50+
],
51+
52+
bundler: viteBundler({}),
53+
})

.vuepress/params.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// 不同仓库需要修改的值
2+
const logoPath = '/image/现代C++并发编程教程.png';
3+
const repoName = '现代C++并发编程教程';
4+
const repoBase = '/ModernCpp-ConcurrentProgramming-Tutorial';
5+
const repoUrl = `https://github.com/Mq-b${repoBase}/`;
6+
7+
export { repoUrl, repoBase, repoName, logoPath }
Loading

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div align="center">
22

33
<a herf="https://zh.cppreference.com/w/cpp/thread">
4-
<img src="image/现代C++并发编程教程.png" width=512px alt="cpp"/>
4+
<img src="/image/现代C++并发编程教程.png" width=512px alt="cpp"/>
55
</a>
66

77
# 现代C++并发编程教程

image/捐赠/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<div align="center">
22

3-
<img src="支付宝10.jpg" width=256px alt="cpp"/>
3+
<img src="./支付宝10.jpg" width=256px alt="cpp"/>
44

5-
<img src="支付宝20.jpg" width=256px alt="cpp"/>
5+
<img src="./支付宝20.jpg" width=256px alt="cpp"/>
66

7-
<img src="支付宝88.88.jpg" width=256px alt="cpp"/>
7+
<img src="./支付宝88.88.jpg" width=256px alt="cpp"/>
88

99
</div>
1010

0 commit comments

Comments
 (0)