-
Notifications
You must be signed in to change notification settings - Fork 1
/
node.d.ts
325 lines (322 loc) · 8.82 KB
/
node.d.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
import { DefaultTheme, UserConfig } from 'vitepress';
import { ElButton } from 'element-plus';
import { FeedOptions } from 'feed';
export { tabsMarkdownPlugin } from 'vitepress-plugin-tabs';
declare namespace BlogPopover {
interface Title {
type: 'title';
content: string;
style?: string;
}
interface Text {
type: 'text';
content: string;
style?: string;
}
interface Image {
type: 'image';
src: string;
style?: string;
}
interface Button {
type: 'button';
link: string;
content: string;
style?: string;
props?: InstanceType<typeof ElButton>['$props'];
}
type Value = Title | Text | Image | Button;
}
type ThemeableImage = string | {
src: string;
alt?: string;
} | {
light: string;
dark: string;
alt?: string;
};
declare namespace Theme {
interface PageMeta {
title: string;
date: string;
tag?: string[];
description?: string;
descriptionHTML?: string;
cover?: string;
hiddenCover?: boolean;
readingTime?: boolean;
sticky?: number;
author?: string;
hidden?: boolean;
layout?: string;
categories: string[];
tags: string[];
/**
* 文章首页置顶
*/
top?: number;
/**
* 手动控制相关文章列表的顺序
*/
recommend?: number | false;
/**
* TODO: 待开发
* 时间线
*/
timeline: string;
/**
* TODO: 待开发
* 专栏&合集
*/
album: string;
publish?: boolean;
}
interface PageData {
route: string;
meta: PageMeta;
}
interface activeTag {
label: string;
type: string;
}
interface GiscusConfig {
repo: string;
repoId: string;
category: string;
categoryId: string;
mapping?: string;
inputPosition?: 'top' | 'bottom';
lang?: string;
loading?: 'lazy' | 'auto' | 'eager';
}
interface HotArticle {
title?: string;
pageSize?: number;
nextText?: string;
empty?: string | boolean;
}
interface RecommendArticle {
title?: string;
pageSize?: number;
nextText?: string;
/**
* 是否展示当前正在浏览的文章在左侧
* @default true
*/
showSelf?: boolean;
filter?: (page: Theme.PageData) => boolean;
empty?: string | boolean;
/**
* 设置推荐文章的展示风格
* @default 'sidebar'
*/
style?: 'card' | 'sidebar';
}
interface HomeBlog {
name?: string;
motto?: string;
inspiring?: string | string[];
inspiringTimeout?: number;
pageSize?: number;
}
interface ArticleConfig {
readingTime?: boolean;
hiddenCover?: boolean;
}
interface Alert {
type: 'success' | 'warning' | 'info' | 'error';
/**
* 细粒度的时间控制
* 默认展示时间,-1 只展示1次,其它数字为每次都展示,一定时间后自动消失,0为不自动消失
* 配置改变时,会重新触发展示
*/
duration: number;
title?: string;
description?: string;
closable?: boolean;
center?: boolean;
closeText?: string;
showIcon?: boolean;
html?: string;
}
interface Popover {
title: string;
/**
* 细粒度的时间控制
* 默认展示时间,-1 只展示1次,其它数字为每次都展示,一定时间后自动消失,0为不自动消失
* 配置改变时,会重新触发展示
*/
duration: number;
body?: BlogPopover.Value[];
footer?: BlogPopover.Value[];
/**
* 手动重新打开
*/
reopen?: boolean;
}
interface FriendLink {
nickname: string;
des: string;
url: string;
avatar: ThemeableImage;
}
interface UserWork {
title: string;
description: string;
time: string | {
start: string;
end?: string;
lastupdate?: string;
};
status?: {
text: string;
type?: 'tip' | 'warning' | 'danger';
};
url?: string;
github?: string | {
owner: string;
repo: string;
branch?: string;
path?: string;
};
cover?: string | string[] | {
urls: string[];
layout?: 'swiper' | 'list';
};
links?: {
title: string;
url: string;
}[];
tags?: string[];
top?: number;
}
type SearchConfig = boolean | 'pagefind' | {
btnPlaceholder?: string;
placeholder?: string;
emptyText?: string;
/**
* @example
* 'Total: {{searchResult}} search results.'
*/
heading?: string;
mode?: boolean | 'pagefind';
};
interface UserWorks {
title: string;
description?: string;
topTitle?: string;
list: UserWork[];
}
type ThemeColor = 'vp-default' | 'vp-green' | 'vp-yellow' | 'vp-red' | 'el-blue' | 'el-yellow' | 'el-green' | 'el-red';
interface BlogConfig {
blog?: false;
/**
* 内置一些主题色
* @default 'vp-default'
* 也可以自定义颜色,详见 TODO:文档
*/
themeColor?: ThemeColor;
pagesData: PageData[];
srcDir?: string;
author?: string;
hotArticle?: HotArticle;
home?: HomeBlog;
/**
* 本地全文搜索定制
* 内置pagefind 实现,
* VitePress 官方提供 minisearch 实现,
* 社区提供 flexsearch 实现
*/
search?: SearchConfig;
/**
* 配置评论
* power by https://giscus.app/zh-CN
*/
comment?: GiscusConfig | false;
/**
* 阅读文章左侧的推荐文章(替代默认的sidebar)
*/
recommend?: RecommendArticle | false;
article?: ArticleConfig;
/**
* el-alert
*/
alert?: Alert;
popover?: Popover;
friend?: FriendLink[];
authorList?: Omit<FriendLink, 'avatar'>[];
/**
* 启用 [vitepress-plugin-tabs](https://www.npmjs.com/package/vitepress-plugin-tabs)
* @default false
*/
tabs?: boolean;
works?: UserWorks;
/**
* https://mermaid.js.org/config/setup/modules/mermaidAPI.html#mermaidapi-configuration-defaults for options
* @default true
*/
mermaid?: any;
/**
* 设置解析 frontmatter 里 date 的时区
* @default 8 => 'UTC+8'
* */
timeZone?: number;
/**
* 启用RSS配置
*/
RSS?: RSSOptions;
}
type RSSOptions = Omit<FeedOptions, 'id'> & {
id?: string;
/**
* 你的站点地址
* @example 'https://sugarat.top'
*/
baseUrl: string;
/**
* 线上访问的RSS地址
* @default
* @example https://sugarat.top/feed.rss
* ```ts
* `${baseUrl + VPConfig.site.base + (filename || 'feed.rss'}`
* ```
*/
url?: string;
/**
* 输出的RSS文件名
* @default 'feed.rss'
*/
filename?: string;
/**
* RSS的图标展示
* @default true
*/
icon?: boolean;
/**
* 限制输出文件包含的文章数量
* @default 0
* @description (0 不限制;> 1 会按照日期排序对输出内容进行调整)
*/
limit?: number;
};
interface Config extends DefaultTheme.Config {
blog?: BlogConfig;
}
interface HomeConfig {
/**
* @deprecated
* 此方法已经废弃,这个定义将在未来某一刻被移除,请为 inspiring 配置数租来实现相同的效果
*/
handleChangeSlogan?: (oldSlogan: string) => string | Promise<string>;
}
}
/**
* 获取主题的配置
* @param cfg 主题配置
*/
declare function getThemeConfig(cfg?: Partial<Theme.BlogConfig>): any;
/**
* defineConfig Helper
*/
declare function defineConfig(config: UserConfig<Theme.Config>): any;
export { defineConfig, getThemeConfig };