feat: auto generate sidebar config (#223)

pull/286/head
Rizumu Ayaka 2023-12-01 21:53:50 +08:00
parent 63492c51ec
commit 08e0524369
5 changed files with 85 additions and 17 deletions

View File

@ -1,9 +1,11 @@
import { defineConfig } from 'vitepress'
import { defineConfig, type DefaultTheme } from 'vitepress'
import nav from './nav'
import mdPangu from "markdown-it-pangu";
import katex from 'markdown-it-katex';
import footnote from 'markdown-it-footnote';
import { getSidebar } from 'vitepress-plugin-auto-sidebar'
import mdPangu from "markdown-it-pangu"
import katex from 'markdown-it-katex'
import footnote from 'markdown-it-footnote'
import { generateSidebar } from 'vitepress-sidebar'
import { sidebar } from './sidebar'
// https://vitepress.dev/reference/site-config
export default defineConfig({
@ -22,12 +24,7 @@ export default defineConfig({
// https://vitepress.dev/reference/default-theme-config
siteTitle: 'RLE.wiki',
nav,
sidebar: getSidebar({
contentRoot: '/docs',
contentDirs: ['campus', 'contributor-guide', 'fashion'],
collapsible: true,
collapsed: true,
}),
sidebar,
socialLinks: [
{ icon: 'github', link: 'https://github.com/project-trans/RLE-wiki' }

View File

@ -1,4 +1,4 @@
import { DefaultTheme } from 'vitepress'
import { type DefaultTheme } from 'vitepress'
const nav = [
{

View File

@ -0,0 +1,28 @@
import { type DefaultTheme } from 'vitepress'
import { generateSidebar } from 'vitepress-sidebar'
export const sidebar = generateSidebar([
// 大学指南
{
documentRootPath: '/docs',
scanStartPath: 'campus',
resolvePath: '/campus/',
useTitleFromFrontmatter: true,
},
// 贡献指南
{
documentRootPath: '/docs',
scanStartPath: 'contributor-guide',
resolvePath: '/contributor-guide/',
useTitleFromFrontmatter: true,
},
// Fashion
{
documentRootPath: '/docs',
scanStartPath: 'fashion',
resolvePath: '/fashion/',
useTitleFromFrontmatter: true,
}
// 这个 `as` 源于 vitepress-sidebar 的类型定义与实际情况的差异,目前不影响使用,后续 vitepress-sidebar 修复后可以移除。
]) as DefaultTheme.Config['sidebar']

View File

@ -20,7 +20,7 @@
"markdown-it-katex": "^2.0.3",
"markdown-it-pangu": "^1.0.2",
"vitepress": "^1.0.0-rc.31",
"vitepress-plugin-auto-sidebar": "^1.1.0",
"vitepress-sidebar": "^1.18.0",
"vue": "^3.3.8",
"vuepress": "2.0.0-rc.0",
"vuepress-theme-hope": "2.0.0-rc.0"

View File

@ -16,15 +16,24 @@ devDependencies:
'@types/markdown-it':
specifier: ^13.0.7
version: 13.0.7
'@vuepress/client':
specifier: 2.0.0-rc.0
version: 2.0.0-rc.0
'@types/markdown-it-footnote':
specifier: ^3.0.3
version: 3.0.3
markdown-it-footnote:
specifier: ^3.0.3
version: 3.0.3
markdown-it-katex:
specifier: ^2.0.3
version: 2.0.3
markdown-it-pangu:
specifier: ^1.0.2
version: 1.0.2
vitepress:
specifier: 1.0.0-rc.31
specifier: ^1.0.0-rc.31
version: 1.0.0-rc.31(@algolia/client-search@4.20.0)(postcss@8.4.31)(search-insights@2.11.0)
vitepress-sidebar:
specifier: ^1.18.0
version: 1.18.0
vue:
specifier: ^3.3.8
version: 3.3.8
@ -2113,6 +2122,12 @@ packages:
dependencies:
'@types/markdown-it': 13.0.7
/@types/markdown-it-footnote@3.0.3:
resolution: {integrity: sha512-sMLBj0VcWo/4vi1J7jx3DNdup2w+14RwDMdQtcFJPabeDwt945ghc8sFBgsUfnEjcBOuKaELY22JwGb7KGmsVw==}
dependencies:
'@types/markdown-it': 13.0.7
dev: true
/@types/markdown-it@13.0.7:
resolution: {integrity: sha512-U/CBi2YUUcTHBt5tjO2r5QV/x0Po6nsYwQU4Y04fBS6vfoImaiZ6f8bi3CjTCxBPQSO1LMyUqkByzi8AidyxfA==}
dependencies:
@ -3919,6 +3934,13 @@ packages:
dependencies:
commander: 8.3.0
/katex@0.6.0:
resolution: {integrity: sha512-rS4mY3SvHYg5LtQV6RBcK0if7ur6plyEukAOV+jGGPqFImuzu8fHL6M752iBmRGoUyF0bhZbAPoezehn7xYksA==}
hasBin: true
dependencies:
match-at: 0.1.1
dev: true
/kind-of@6.0.3:
resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==}
engines: {node: '>=0.10.0'}
@ -4033,6 +4055,16 @@ packages:
/markdown-it-emoji@2.0.2:
resolution: {integrity: sha512-zLftSaNrKuYl0kR5zm4gxXjHaOI3FAOEaloKmRA5hijmJZvSjmxcokOLlzycb/HXlUFWzXqpIEoyEMCE4i9MvQ==}
/markdown-it-footnote@3.0.3:
resolution: {integrity: sha512-YZMSuCGVZAjzKMn+xqIco9d1cLGxbELHZ9do/TSYVzraooV8ypsppKNmUJ0fVH5ljkCInQAtFpm8Rb3eXSrt5w==}
dev: true
/markdown-it-katex@2.0.3:
resolution: {integrity: sha512-nUkkMtRWeg7OpdflamflE/Ho/pWl64Lk9wNBKOmaj33XkQdumhXAIYhI0WO03GeiycPCsxbmX536V5NEXpC3Ng==}
dependencies:
katex: 0.6.0
dev: true
/markdown-it-pangu@1.0.2:
resolution: {integrity: sha512-rssyYaMKXRLMpQIUgX01VE1KYOHhlnc4t5zGTI2zgXDpE88eQz8hywa0iSzoFm3eb5CYzFWazDKdUbnyZvW0SQ==}
dependencies:
@ -4061,6 +4093,10 @@ packages:
uc.micro: 1.0.6
dev: true
/match-at@0.1.1:
resolution: {integrity: sha512-h4Yd392z9mST+dzc+yjuybOGFNOZjmXIPKWjxBd1Bb23r4SmDOsk2NYCU2BMUBGbSpZqwVsZYNq26QS3xfaT3Q==}
dev: true
/mdast-util-to-hast@13.0.2:
resolution: {integrity: sha512-U5I+500EOOw9e3ZrclN3Is3fRpw8c19SMyNZlZ2IS+7vLsNzb2Om11VpIVOR+/0137GhZsFEF6YiKD5+0Hr2Og==}
dependencies:
@ -5138,6 +5174,13 @@ packages:
fsevents: 2.3.3
dev: true
/vitepress-sidebar@1.18.0:
resolution: {integrity: sha512-Ki9ZpNa0CUNr7kovAbAEJ5v4MEZi+dte8Bz3OxkQcjFqrOGfQGEoGATRgf9m6N741epLLB3PFdaUCN6ZH0zmhg==}
engines: {node: '>=18.0.0'}
dependencies:
gray-matter: 4.0.3
dev: true
/vitepress@1.0.0-rc.31(@algolia/client-search@4.20.0)(postcss@8.4.31)(search-insights@2.11.0):
resolution: {integrity: sha512-ikH9pIjOOAbyoYAGBVfTz8TzuXp+UoWaIRMU4bw/oiTg8R65SbAaGKY84xx6TuL+f4VqUJ8lhzW82YyxSLvstA==}
hasBin: true