-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.ts
148 lines (146 loc) · 3.99 KB
/
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import process from 'node:process'
import { getDirname, path } from '@vuepress/utils'
import { defaultTheme, defineUserConfig } from 'vuepress'
import { mdEnhancePlugin } from 'vuepress-plugin-md-enhance'
import { copyCodePlugin } from 'vuepress-plugin-copy-code2'
import { searchProPlugin } from 'vuepress-plugin-search-pro'
import { autoCatalogPlugin } from 'vuepress-plugin-auto-catalog'
import { shikiPlugin } from '@vuepress/plugin-shiki'
import { slug as slugify } from 'github-slugger'
const __dirname = getDirname(import.meta.url)
const isProd = process.env.NODE_ENV === 'production'
const ROOT_PATH = path.resolve(__dirname, '../..')
const CURRENT_PATH = path.resolve(__dirname, '.')
const USER_NAME = 'Sun-ZhenXing'
const BASE_PATH = '/vuepress-python-notes/'
export default defineUserConfig({
lang: 'zh-CN',
title: 'Python 笔记',
description: 'Python 笔记',
head: [
['link', { rel: 'icon', href: `${BASE_PATH}favicon.svg` }],
],
base: BASE_PATH,
markdown: {
code: {
lineNumbers: 10,
},
importCode: {
handleImportPath: str => str
.replace(/^\//, ROOT_PATH.replace(/(?:|\\|\/)$/, '/'))
.replace(/^@\//, CURRENT_PATH.replace(/(?:|\\|\/)$/, '/')),
},
anchor: {
level: [1, 2, 3, 4, 5, 6],
slugify,
},
},
theme: defaultTheme({
logo: '/favicon.svg',
repo: `${USER_NAME}${BASE_PATH}`,
docsDir: 'docs',
selectLanguageName: '简体中文',
selectLanguageText: '选择语言',
selectLanguageAriaLabel: '选择语言',
editLinkText: '在 GitHub 上编辑此页',
contributorsText: '贡献者',
lastUpdatedText: '上次更新',
openInNewWindow: '在新窗口打开',
toggleColorMode: '切换颜色模式',
toggleSidebar: '切换侧边栏',
tip: '提示',
warning: '注意',
danger: '警告',
notFound: [
'这里什么都没有',
'我们怎么到这来了?',
'这是一个 404 页面',
'看起来我们进入了错误的链接',
],
backToHome: '返回首页',
navbar: [
],
sidebar: 'auto',
themePlugins: {
git: isProd,
},
}),
plugins: [
mdEnhancePlugin({
gfm: true,
hint: true,
vPre: true,
tabs: true,
codetabs: true,
include: {
resolvePath: (file) => {
if (file.startsWith('@/'))
return file.replace(/^@\//, CURRENT_PATH)
if (file.startsWith('/'))
return file.replace(/^\//, ROOT_PATH.replace(/(?:|\\|\/)$/, '/'))
return file
},
},
align: true,
attrs: true,
sub: true,
sup: true,
footnote: true,
mark: true,
imgLazyload: true,
tasklist: true,
katex: {
copy: true,
},
mermaid: true,
delay: 200,
stylize: [
{
matcher: '@def',
replacer: ({ tag }) => {
if (tag === 'em') {
return {
tag: 'Badge',
attrs: { type: 'tip' },
content: '定义',
}
}
},
},
{
matcher: /@3.[0-9]+\+/,
replacer: ({ tag, content }) => {
if (tag === 'em') {
return {
tag: 'Badge',
attrs: { type: 'tip' },
content: content.replace('@', ''),
}
}
},
},
{
matcher: '@TODO',
replacer: ({ tag }) => {
if (tag === 'em') {
return {
tag: 'Badge',
attrs: { type: 'danger' },
content: 'TODO',
}
}
},
},
],
}, false),
searchProPlugin({}),
autoCatalogPlugin({}),
copyCodePlugin({
showInMobile: true,
}),
shikiPlugin({ theme: 'dark-plus' }),
],
alias: {
'@': CURRENT_PATH,
},
})