Skip to content

Commit 770a5ab

Browse files
committed
refactor: build site with vitepress
1 parent 5b9ff64 commit 770a5ab

34 files changed

+326
-173
lines changed

.github/workflows/deploy.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Build and deploy
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
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: interview.doocs.org
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
41+
build:
42+
runs-on: ubuntu-latest
43+
if: github.repository == 'doocs/coding-interview'
44+
needs: docs
45+
steps:
46+
- name: Sync to Gitee
47+
uses: wearerequired/git-mirror-action@master
48+
env:
49+
SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }}
50+
with:
51+
source-repo: [email protected]:doocs/coding-interview.git
52+
destination-repo: [email protected]:Doocs/coding-interview.git

.github/workflows/sync.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ hs_err_pid*
2424

2525
node_modules
2626
*.json
27+
28+
29+
docs/.vitepress/dist
30+
docs/.vitepress/cache

.nojekyll

Whitespace-only changes.

CNAME

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

_coverpage.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

_navbar.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

docs/.vitepress/config.mts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { defineConfig } from 'vitepress'
2+
3+
// https://vitepress.dev/reference/site-config
4+
export default defineConfig({
5+
title: "coding-interview",
6+
description: "互联网公司 IT 技术面试题集",
7+
themeConfig: {
8+
// https://vitepress.dev/reference/default-theme-config
9+
nav: [
10+
{ text: '首页', link: '/' },
11+
{ text: '题解', link: '/coding-interview' },
12+
{ text: '编程之美', link: '/the-beauty-of-programming' },
13+
{ text: '代码整洁之道', link: '/clean-code' },
14+
{ text: '阿里巴巴 Java 开发手册', link: '/effective-coding' },
15+
{ text: '枕边算法书', link: '/algorithm-stories' },
16+
{ text: 'Effective Java', link: '/effective-java' }
17+
],
18+
search: {
19+
provider: 'local'
20+
},
21+
logo: '/favicon-32x32.png',
22+
footer: {
23+
message: 'Released under the CC-BY-SA-4.0 license.',
24+
copyright: `版权所有 © 2018-${new Date().getFullYear()} <a href="https://github.com/doocs">Doocs</a>`
25+
},
26+
docFooter: {
27+
prev: '上一篇',
28+
next: '下一篇'
29+
},
30+
editLink: {
31+
pattern: 'https://github.com/doocs/coding-interview/edit/main/docs/:path',
32+
text: '在 GitHub 编辑'
33+
},
34+
sidebar: [
35+
{
36+
text: '📚 题解',
37+
items: [
38+
{ text: '剑指 Offer', link: '/coding-interview' },
39+
{ text: '编程之美', link: '/the-beauty-of-programming' }
40+
]
41+
},
42+
{
43+
text: '📝 代码整洁',
44+
items: [
45+
{ text: '代码整洁之道', link: '/clean-code' },
46+
{ text: '阿里巴巴 Java 开发手册', link: '/effective-coding' }
47+
]
48+
},
49+
{
50+
text: '📖 其他书籍',
51+
items: [
52+
{ text: '枕边算法书', link: '/algorithm-stories' },
53+
{ text: 'Effective Java', link: '/effective-java' }
54+
]
55+
}
56+
],
57+
58+
socialLinks: [
59+
{ icon: 'github', link: 'https://github.com/doocs/coding-interview' }
60+
]
61+
},
62+
head: [
63+
['link', { rel: 'icon', type: 'image/png', href: '/favicon-32x32.png' }],
64+
],
65+
cleanUrls: true,
66+
sitemap: {
67+
hostname: 'https://interview.doocs.org'
68+
}
69+
})

docs/.vitepress/theme/Layout.vue

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<Layout>
3+
<template #doc-footer-before>
4+
<div
5+
style="
6+
margin-top: 40px;
7+
padding: 2em 0;
8+
text-align: center;
9+
border-top: 1px solid #e2e2e2;
10+
"
11+
>
12+
<table style="margin: 0 auto">
13+
<tbody>
14+
<tr>
15+
<td align="center" style="width: 260px">
16+
<img
17+
src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/images/qrcode-for-doocs.png"
18+
style="width: 200px"
19+
/><br />
20+
</td>
21+
<td align="center" style="width: 260px">
22+
<img
23+
src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/images/qrcode-for-yanglbme.png"
24+
style="width: 200px"
25+
/><br />
26+
</td>
27+
</tr>
28+
</tbody>
29+
</table>
30+
</div>
31+
</template>
32+
</Layout>
33+
</template>
34+
35+
<script setup>
36+
import DefaultTheme from 'vitepress/theme';
37+
const { Layout } = DefaultTheme;
38+
</script>

docs/.vitepress/theme/index.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
import Layout from "./Layout.vue";
6+
7+
export default {
8+
extends: DefaultTheme,
9+
Layout: Layout,
10+
enhanceApp(ctx) {
11+
DefaultTheme.enhanceApp(ctx);
12+
},
13+
setup() {
14+
const { frontmatter } = toRefs(useData());
15+
const route = useRoute();
16+
17+
giscusTalk(
18+
{
19+
repo: "doocs/coding-interview",
20+
repoId: "MDEwOlJlcG9zaXRvcnkxNTQ5MTMxODI=",
21+
mapping: "pathname",
22+
category: "Announcements",
23+
categoryId: "IC_kwDOCTvJns4CpHBe",
24+
inputPosition: "top",
25+
lang: "zh-CN",
26+
homePageShowComment: true,
27+
loading: "lazying",
28+
lightTheme: "light",
29+
darkTheme: "transparent_dark",
30+
},
31+
{
32+
frontmatter,
33+
route,
34+
},
35+
true
36+
);
37+
},
38+
};

0 commit comments

Comments
 (0)