diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
new file mode 100644
index 0000000..0d04b09
--- /dev/null
+++ b/.github/workflows/deploy.yml
@@ -0,0 +1,62 @@
+# 构建 VitePress 站点并将其部署到 GitHub Pages 的示例工作流程
+#
+name: Deploy VitePress site to Pages
+
+on:
+ # 在针对 `main` 分支的推送上运行。如果你
+ # 使用 `master` 分支作为默认分支,请将其更改为 `master`
+ push:
+ branches: [main, vitepress]
+
+ # 允许你从 Actions 选项卡手动运行此工作流程
+ workflow_dispatch:
+
+# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
+permissions:
+ contents: read
+ pages: write
+ id-token: write
+
+# 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
+# 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成
+concurrency:
+ group: pages
+ cancel-in-progress: false
+
+jobs:
+ # 构建工作
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0 # 启用 lastUpdated 需要开启这项
+ - name: Setup Node
+ uses: actions/setup-node@v4
+ with:
+ node-version: 20
+ # cache: npm 难道开启缓存,需要 lock 文件?没错!
+ - name: Setup Pages
+ uses: actions/configure-pages@v4
+ - name: Install dependencies
+ run: npm install # 不使用 ci,因为我没有上传 lock 文件
+ - name: Build with VitePress
+ run: npm run docs:build -- --base /note/
+ - name: Upload artifact
+ uses: actions/upload-pages-artifact@v3
+ with:
+ path: .vitepress/dist
+
+ # 部署工作
+ deploy:
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}
+ needs: build
+ runs-on: ubuntu-latest
+ name: Deploy
+ steps:
+ - name: Deploy to GitHub Pages
+ id: deployment
+ uses: actions/deploy-pages@v4
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..7c4783d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+pnpm-lock.yaml
+node_modules
+.vitepress/cache
+.vitepress/dist
\ No newline at end of file
diff --git a/.vitepress/config.mjs b/.vitepress/config.mjs
new file mode 100644
index 0000000..24bbcf5
--- /dev/null
+++ b/.vitepress/config.mjs
@@ -0,0 +1,86 @@
+import { defineConfig } from 'vitepress'
+import fs from 'node:fs'
+import { join, extname, basename } from 'node:path'
+
+const nav = [
+ // { pathPrefix: '/web/', dir: 'web/', text: 'web 相关', link: '/web/README' },
+ // { pathPrefix: '/vscode/', dir: 'vscode/', text: 'vscode', link: '/vscode/README' },
+ { pathPrefix: '/DSA/', dir: 'DSA/', text: '数据结构与算法', link: '/DSA/README' },
+ // { pathPrefix: '/CLI/', dir: 'CLI/', text: '命令行', link: '/CLI/README' },
+ // { pathPrefix: '/interview/', dir: 'interview/', text: '面试相关', link: '/interview/css' },
+]
+const getNav = () => nav.map(item => ({ text: item.text, link: item.link }))
+
+function dfsReadme(dir) {
+ const ans = []
+ const subFiles = fs.readdirSync(dir)
+ subFiles.sort((a,b) => {
+ // 我要让以 _ 开头的排在前面
+ if (a.startsWith('_') && !b.startsWith('_')) return -1
+ else if (!a.startsWith('_') && b.startsWith('_')) return 1
+ return a-b
+ })
+
+ for (const child of subFiles) {
+ const childPath = join(dir, child)
+ if (isDir(childPath)) {
+ const items = dfsReadme(childPath)
+ if (items.length > 0) {
+ ans.push({
+ text: basename(childPath, '.md'),
+ items
+ })
+
+ }
+ } else if (extname(childPath) === '.md') {
+ ans.push({
+ text: basename(childPath, '.md'),
+ link: childPath
+ })
+ }
+ }
+ return ans
+}
+/**
+ * 不同页面路径,输出不同的侧边栏
+ */
+function getOneSidebar(pathPrefix) {
+ const sidebar = dfsReadme(pathPrefix)
+
+ return sidebar
+ .filter(v => !(v.text === 'README.md' || v.text === 'README'))
+ .map(v => ({ ...v, collapsed: true }))
+}
+function getSideBar() {
+ const sidebar = {}
+ nav.forEach(item => {
+ sidebar[item.pathPrefix] = getOneSidebar(item.dir)
+ })
+ return sidebar
+}
+function isDir(url) {
+ return !fs.statSync(url).isFile()
+}
+
+// https://vitepress.dev/reference/site-config
+export default defineConfig({
+ title: "我的笔记",
+ description: "A VitePress Site",
+ markdown: {
+ math: true
+ },
+
+ themeConfig: {
+ nav: getNav(),
+ sidebar: getSideBar(),
+ lastUpdated: true,
+
+ editLink: {
+ text: '在 Github 上查看此页',
+ pattern: 'https://github.com/linhieng/note/tree/main/:path'
+ },
+ socialLinks: [
+ { icon: 'github', link: 'https://github.com/linhieng/note' }
+ ]
+ }
+})
diff --git a/index.md b/index.md
new file mode 100644
index 0000000..59397fe
--- /dev/null
+++ b/index.md
@@ -0,0 +1,27 @@
+---
+layout: home
+
+title: Note
+titleTemplate: Linhieng
+
+hero:
+ name: Linhieng 的笔记
+ actions:
+ - theme: brand
+ text: 首页
+ link: /README
+ - theme: alt
+ text: 个人网站
+ link: https://oonoo.cn
+
+features:
+ - icon: 📝
+ title: 长期更新
+ details: 相信我,我能做到!如果做不到,我肯定会关掉这个网站的😂
+ - icon: 🚀
+ title: 速度超快
+ details: 本笔记基于 VitePress 进行部署,速度嘎嘎快。
+ - icon:
+ title: 开源
+ details: 你可以直接在 Github 上查看笔记,同时指出相关错误。
+---
\ No newline at end of file
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..c6ce9d4
--- /dev/null
+++ b/package.json
@@ -0,0 +1,11 @@
+{
+ "devDependencies": {
+ "markdown-it-mathjax3": "^4.3.2",
+ "vitepress": "^1.1.0"
+ },
+ "scripts": {
+ "docs:dev": "vitepress dev",
+ "docs:build": "vitepress build",
+ "docs:preview": "vitepress preview"
+ }
+}
\ No newline at end of file