Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use VitePress build #541

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
.ipynb_checkpoints
.DS_Store
.gitignore
*.ipynb
.idea
.vscode
.history
node_modules
.vitepress/cache
.vitepress/dist
Empty file removed .nojekyll
Empty file.
45 changes: 45 additions & 0 deletions .vitepress/config/en-us.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { type DefaultTheme, defineConfig } from "vitepress"

export default defineConfig({
lang: "en-us",
title: "Deep Learning 500 Questions",
themeConfig: {

sidebar: {
"/en-us/": { base: "/en-us/", items: sidebarGuide() },
},

editLink: {
pattern: "https://github.com/scutan90/DeepLearning-500-questions/edit/master/:path",
text: "Edit this page on GitHub",
},

docFooter: {
prev: "Last Page",
next: "Next Page",
},

footer: {
message: "Released under the MIT License.",
copyright: "Copyright © 2018-present scutan90",
},

lastUpdated: {
text: "Last updated at",
formatOptions: {
dateStyle: "short",
timeStyle: "medium",
},
},
},
})

export function sidebarGuide(): DefaultTheme.SidebarItem[] {
return [
{ text: "guide", link: "README" },
{ text: "Chapter 1", link: "ch01_MathematicalBasis/MathematicalBasis" },
{ text: "Chapter 2", link: "ch02_MachineLearningFoundation/TheBasisOfMachineLearning" },
{ text: "Chapter 3", link: "ch03_DeepLearningFoundation/DeepLearningFoundation" },
{ text: "Chapter 4", link: "ch04_ClassicNetwork/ClassicNetwork" },
]
}
19 changes: 19 additions & 0 deletions .vitepress/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from "vitepress"
import shared from "./shared"
import en_us, { sidebarGuide as EN_side } from "./en-us"
import zh_cn, { sidebarGuide as ZH_side } from "./zh-cn"
import handleRewrites from "../utils/rewrites"

const en = { lang: "en-us", list: EN_side() }
const zh = { lang: "zh-cn", list: ZH_side() }
const rewrites = handleRewrites(en, zh)
// console.log(rewrites)

export default defineConfig({
...shared,
locales: {
"en-us": { label: "English", ...en_us },
root: { label: "简体中文", ...zh_cn },
},
// rewrites,
})
27 changes: 27 additions & 0 deletions .vitepress/config/shared.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { defineConfig } from "vitepress"

export default defineConfig({
title: "深度学习500问",

lastUpdated: true,
cleanUrls: true,
metaChunk: true,

markdown: {
math: true,
},
ignoreDeadLinks: true,

themeConfig: {
socialLinks: [
{ icon: "github", link: "https://github.com/scutan90/DeepLearning-500-questions" },
],
},
head: [
["meta", { property: "og:locale", content: "zh" }],
],

vite: {
assetsInclude: ["**/*.jpg", "**/*.jpeg", "**/*.bmp", "**/*.JPEG"],
},
})
73 changes: 73 additions & 0 deletions .vitepress/config/zh-cn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { type DefaultTheme, defineConfig } from "vitepress"

export default defineConfig({
lang: "zh-cn",
themeConfig: {

sidebar: {
"/": { base: "/", items: sidebarGuide() },
},

editLink: {
pattern: "https://github.com/scutan90/DeepLearning-500-questions/edit/master/:path",
text: "在 GitHub 上编辑此页面",
},

docFooter: {
prev: "上一页",
next: "下一页",
},

footer: {
message: "基于 MIT 许可发布",
copyright: `版权所有 © 2018-${new Date().getFullYear()} scutan90`,
},

outline: {
label: "页面导航",
},

lastUpdated: {
text: "最后更新于",
formatOptions: {
dateStyle: "short",
timeStyle: "medium",
},
},

langMenuLabel: "多语言",
returnToTopLabel: "回到顶部",
sidebarMenuLabel: "菜单",
darkModeSwitchLabel: "主题",
lightModeSwitchTitle: "切换到浅色模式",
darkModeSwitchTitle: "切换到深色模式",
},
})

export function sidebarGuide(): DefaultTheme.SidebarItem[] {
return [
{ text: "简介", link: "README" },
{ text: "第一章", link: "ch01_数学基础/第一章_数学基础" },
{ text: "第二章", link: "ch02_机器学习基础/第二章_机器学习基础" },
{ text: "第三章", link: "ch03_深度学习基础/第三章_深度学习基础" },
{ text: "第四章", link: "ch04_经典网络/第四章_经典网络" },
{ text: "第五章", link: "ch05_卷积神经网络(CNN)/第五章_卷积神经网络(CNN)" },
{ text: "第六章", link: "ch06_循环神经网络(RNN)/第六章_循环神经网络(RNN)" },
{ text: "第七章", link: "ch07_生成对抗网络(GAN)/ch7" },
{ text: "第八章", link: "ch08_目标检测/第八章_目标检测" },
{ text: "第九章", link: "ch09_图像分割/第九章_图像分割" },
{ text: "第十章", link: "ch10_强化学习/第十章_强化学习" },
{ text: "第十一章", link: "ch11_迁移学习/第十一章_迁移学习" },
{ text: "第十二章", link: "ch12_网络搭建及训练/第十二章_网络搭建及训练" },
{ text: "第十三章", link: "ch13_优化算法/第十三章_优化算法" },
{ text: "第十四章", link: "ch14_超参数调整/第十四章_超参数调整" },
{ text: "第十五章", link: "ch15_GPU和框架选型/第十五章_异构运算、GPU及框架选型" },
{ text: "第十六章", link: "ch16_自然语言处理(NLP)/第十六章_NLP" },
{ text: "第十七章", link: "ch17_模型压缩、加速及移动端部署/第十七章_模型压缩、加速及移动端部署" },
{ text: "第十八章", link: "ch18_后端架构选型、离线及实时计算/第十八章_后端架构选型、离线及实时计算" },
{ text: "第十八章", link: "ch18_后端架构选型及应用场景/第十八章_后端架构选型及应用场景" },
{ text: "第十九章", link: "ch19_软件专利申请及权利保护/第十九章_软件专利申请及权利保护" },
]
}


7 changes: 7 additions & 0 deletions .vitepress/theme/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pre, mjx-container {
overflow-x: auto;
}

mjx-container {
position: static!important;
}
4 changes: 4 additions & 0 deletions .vitepress/theme/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import DefaultTheme from "vitepress/theme"
import "./custom.css"

export default DefaultTheme
25 changes: 25 additions & 0 deletions .vitepress/utils/rewrites.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { DefaultTheme } from "vitepress"

type Sidebars = DefaultTheme.SidebarItem[]

interface ISides {
lang: string
list: Sidebars
}

export default function rewrites(froms: ISides, tos: ISides) {
const from = froms.list.map(({ link }) => link)
const to = tos.list.map(({ link }) => link)

const rewrites: Record<string, string> = {}

from.forEach((item, i) => {
rewrites[`${froms.lang}/${item}.md`] = `${froms.lang}/${to[i]}.md`
})

to.forEach((item, i) => {
rewrites[`${item}.md`] = `${from[i]}.md`
})

return rewrites
}
Loading