Skip to content

Commit 75f23e5

Browse files
committed
refactor: build site with vitepress
1 parent 49f256f commit 75f23e5

File tree

12 files changed

+2300
-1708
lines changed

12 files changed

+2300
-1708
lines changed

.github/workflows/sync.yml

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,52 @@
1-
name: Sync
1+
name: Build and deploy
22

33
on:
44
push:
55
branches: [main]
6+
workflow_dispatch:
67

78
jobs:
9+
docs:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 22
21+
cache: npm
22+
23+
- name: Setup Pages
24+
uses: actions/configure-pages@v4
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Build with VitePress
30+
run: npm run docs:build
31+
32+
- name: Deploy to GitHub Pages
33+
uses: crazy-max/ghaction-github-pages@v4
34+
with:
35+
target_branch: gh-pages
36+
build_dir: docs/.vitepress/dist
37+
fqdn: book.doocs.org
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
841
build:
942
runs-on: ubuntu-latest
1043
if: github.repository == 'doocs/technical-books'
44+
needs: docs
1145
steps:
12-
- uses: actions/checkout@v3
13-
1446
- name: Sync to Gitee
1547
uses: wearerequired/git-mirror-action@master
1648
env:
1749
SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }}
1850
with:
1951
source-repo: git@github.com:doocs/technical-books.git
20-
destination-repo: git@gitee.com:Doocs/technical-books.git
21-
22-
- name: Build Gitee Pages
23-
uses: yanglbme/gitee-pages-action@main
24-
with:
25-
gitee-username: yanglbme
26-
gitee-password: ${{ secrets.GITEE_PASSWORD }}
27-
gitee-repo: doocs/technical-books
28-
branch: main
52+
destination-repo: git@gitee.com:Doocs/technical-books.git

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
.vscode
44
.temp
55
.cache
6-
/node_modules
6+
/node_modules
7+
docs/.vitepress/dist
8+
docs/.vitepress/cache

CNAME

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/.vitepress/config.mts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { defineConfig } from 'vitepress'
2+
3+
// https://vitepress.dev/reference/site-config
4+
export default defineConfig({
5+
title: "Technical Books",
6+
description: "值得一看的技术类书籍列表",
7+
themeConfig: {
8+
// https://vitepress.dev/reference/default-theme-config
9+
nav: [
10+
{ text: '首页', link: '/' },
11+
],
12+
search: {
13+
provider: 'local'
14+
},
15+
footer: {
16+
message: 'Released under the CC-BY-SA-4.0 license.',
17+
copyright: `Copyright © 2018-${new Date().getFullYear()} <a href="https://github.com/doocs">Doocs</a>`
18+
},
19+
logo: '/favicon-32x32.png',
20+
editLink: {
21+
pattern: 'https://github.com/doocs/technical-books/edit/main/docs/:path',
22+
text: '在 GitHub 编辑'
23+
},
24+
25+
socialLinks: [
26+
{ icon: 'github', link: 'https://github.com/doocs/technical-books' }
27+
]
28+
},
29+
head: [
30+
['link', { rel: 'icon', type: 'image/png', href: '/favicon.png' }],
31+
[
32+
'script',
33+
{ async: '', src: 'https://www.googletagmanager.com/gtag/js?id=G-FXKXWXY4HF' }
34+
],
35+
[
36+
'script',
37+
{},
38+
`window.dataLayer = window.dataLayer || [];
39+
function gtag(){dataLayer.push(arguments);}
40+
gtag('js', new Date());
41+
gtag('config', 'G-FXKXWXY4HF');`
42+
]
43+
],
44+
cleanUrls: true,
45+
sitemap: {
46+
hostname: 'https://book.doocs.org'
47+
}
48+
})

docs/.vitepress/theme/index.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import DefaultTheme from 'vitepress/theme';
2+
import giscusTalk from 'vitepress-plugin-comment-with-giscus';
3+
import { useData, useRoute } from 'vitepress';
4+
import { toRefs } from "vue";
5+
6+
export default {
7+
...DefaultTheme,
8+
enhanceApp(ctx) {
9+
DefaultTheme.enhanceApp(ctx);
10+
},
11+
setup() {
12+
const { frontmatter } = toRefs(useData());
13+
const route = useRoute();
14+
15+
giscusTalk({
16+
repo: 'doocs/technical-books',
17+
repoId: 'MDEwOlJlcG9zaXRvcnkxNzgwMjQ5NDk=',
18+
mapping: 'number',
19+
inputPosition: 'top',
20+
lang: 'zh-CN',
21+
homePageShowComment: true,
22+
term: '30',
23+
lightTheme: 'light',
24+
darkTheme: 'transparent_dark',
25+
}, {
26+
frontmatter,
27+
route
28+
}, true);
29+
}
30+
};

docs/index.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
# https://vitepress.dev/reference/default-theme-home-page
3+
layout: home
4+
5+
hero:
6+
name: "Technical Books"
7+
text: "值得一看的技术类书籍列表"
8+
tagline: Doocs 技术社区出品
9+
actions:
10+
- theme: alt
11+
text: GitHub
12+
link: https://github.com/doocs
13+
- theme: brand
14+
text: 进入
15+
link: /intro
16+
17+
features:
18+
- title: 计算机系统与算法 📚
19+
details: 计算机基础知识,涵盖计算机系统原理、算法设计、操作系统、编译原理等方面的经典教材。
20+
- title: 计算机网络 🌐
21+
details: 深入了解计算机网络基础,包括网络协议、HTTP、TCP/IP、计算机网络的原理与应用。
22+
- title: 后端开发 🖥️
23+
details: 针对后端开发的技术书籍,涵盖 Java、Python、Go、Node.js 等编程语言与高并发系统设计。
24+
- title: 数据库 🗃️
25+
details: 讲解数据库底层原理和优化技巧,涵盖 Redis、MySQL、HBase 等数据库技术。
26+
- title: 前端开发 💻
27+
details: 前端技术书籍,包括 JavaScript 高级编程技巧、设计模式、以及 Three.js 和 Web 开发实战。
28+
- title: 架构 🏗️
29+
details: 介绍现代系统架构设计的核心原理及实践,适用于互联网公司高并发、高可用性技术架构。
30+
- title: 大数据 📊
31+
details: 探索大数据领域的技术,包括 Spark、Hadoop、Elasticsearch 等,适用于分布式数据处理与分析。
32+
- title: 工具 🛠️
33+
details: 提供对开发工具的深入理解和实用技巧,包括 Git、Vim、GitHub 等开发工具的使用。
34+
- title: 其他 🔗
35+
details: 提供各种免费编程书籍的资源,帮助开发者拓宽知识面。
36+
---
37+

0 commit comments

Comments
 (0)