-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvuepress.config.ts
74 lines (60 loc) · 1.96 KB
/
vuepress.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import fs from 'fs'
import path from 'path'
import frontmatter from 'frontmatter'
import { SidebarItem, defaultTheme, defineUserConfig } from 'vuepress'
const sourceDir = __dirname
function generateSidebarFrom(dir: string): Array<SidebarItem> {
return fs.readdirSync(dir, { withFileTypes: true })
.filter(item => item.isDirectory() && fs.existsSync(path.join(dir, item.name, 'README.md')))
.map(item => {
const data: any = frontmatter(fs.readFileSync(path.join(dir, item.name, 'README.md')).toString())?.data || {}
return {
text: data.title || item.name,
link: '/' + path.relative(__dirname, path.join(dir, item.name)).replace(/\\/g, '/') + '/',
}
})
}
export default defineUserConfig({
lang: 'zh-CN',
title: 'InsaneMC',
description: '疯狂的 Minecraft 数据包构建工具',
head: [
['link', { rel: "shortcut icon", href: "/logo.png" }],
['meta', { name: "msapplication-TileColor", content: "#3eaf7c" }],
['meta', { name: "theme-color", content: "#ffffff" }],
],
base: '/',
public: `${sourceDir}/.vuepress/assets`,
theme: defaultTheme({
// logo: '/avatar.png',
repo: 'insane-mc/imc',
docsRepo: 'insane-mc/docs',
contributors: false,
lastUpdatedText: '上次更新',
editLinkText: '帮助我们改善此页面',
navbar: [
{ text: '入门指南', link: '/intro/' },
{ text: 'API 文档', link: '/api/' },
{ text: 'IMCL 文档', link: '/imcl/' },
{ text: '官方实践', link: '/packages/' },
],
sidebar: {
'/intro/': [
{ text: '快速上手', link: '/intro/' },
{ text: 'README.md (EN)', link: '/intro/readme-en/' }
],
'/api/': [
{ text: 'API 文档', link: '/api/' },
...generateSidebarFrom(path.join(__dirname, 'api')),
],
'/imcl/': [
{ text: 'IMCL 文档', link: '/imcl/' },
...generateSidebarFrom(path.join(__dirname, 'imcl')),
],
'/packages/': [
{ text: '官方实践', link: '/packages/' },
...generateSidebarFrom(path.join(__dirname, 'packages')),
],
},
}),
})