/
config.ts
402 lines (373 loc) · 8.24 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
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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
import type { ZoomOptions } from 'medium-zoom'
import type { FuseOptions } from '@vueuse/integrations/useFuse'
import type { ILazyLoadOptions } from 'vanilla-lazyload'
import type { RouteRecordRaw } from 'vue-router'
import type { ValaxyAddon } from '../types'
import type { DefaultTheme } from './default-theme'
import type { PostFrontMatter } from './posts'
import type { FuseListItem } from './node'
import './default-theme'
/**
* @zh 社交链接
*/
export interface SocialLink {
/**
* The title of your link
*/
name: string
link: string
/**
* 图标名称
* https://icones.js.org/
*/
icon: string
/**
* @zh 图标颜色
*/
color: string
}
export interface RedirectRule {
to: string
from: string | string[]
}
export interface RedirectItem {
from: string
to: string
}
// shared with valaxy node and client
export interface SiteConfig {
/**
* enable auto (light/dark mode)
* @default 'auto'
*/
mode: 'light' | 'dark' | 'auto'
/**
* Default language
* @description 默认语言,设置 `zh-CN` 以改变默认语言为中文
* @default 'en'
*/
lang: string
/**
* alternative languages
* @description 可选语言
* @default ['en', 'zh-CN']
* @see https://ogp.me/#optional
*/
languages: string[]
/**
* @see https://day.js.org/docs/en/plugin/timezone
* @zh_CN 时区 'Asia/Shanghai' Recommended
* @en_US timezone
* @default '' Your Computer Timezone
*/
timezone: string
/**
* You site url in web, required for ssg & rss
* @description 站点的完整 URL,SSG & RSS 需要(譬如生成版权处文章永久链接)
* @example 'https://valaxy.site'
* @default '/'
*/
url: string
/**
* Site title
* @description 站点标题
*/
title: string
/**
* 副标题
*/
subtitle: string
/**
* 站点描述
*/
description: string
/**
* The owner of this blog
* @description 博客作者
*/
author: {
/**
* Your name
* @description 你的名字
*/
name: string
email: string
link: string
avatar: string
/**
* The status of you
* @description 状态
*/
status: {
emoji: string
/**
* show when hover emoji
* @description 当鼠标悬浮在图标上时显示
*/
message: string
}
}
/**
* show last updated time by git/mtime
*/
lastUpdated: boolean
/**
* icon for your website
*/
favicon: string
feed: {
/**
* name: feed -> feed.xml / feed.atom / feed.json
* @default '' -> feed.xml / atom.xml / feed.json
*/
name: string
favicon: string
}
/**
* 社交链接
*/
social: SocialLink[]
/**
* search
*/
search: {
enable: boolean
/**
* Search Type
* - algolia: Algolia Search
* - engine: Engine Search, like Google/Baidu
* - fuse: Local Search by fuse.js
*/
type: 'algolia' | 'engine' | 'fuse'
}
/**
*
* fuse search
* @see https://fusejs.io/
* @description 本地搜索
* Please set search.type to 'fuse'
*/
fuse: {
/**
* @default 'valaxy-fuse-list.json'
* @description 搜索结果列表数据所在路径
*/
dataPath: string
/**
* @see https://fusejs.io/api/options.html
*/
options: FuseOptions<FuseListItem> & {
/**
* @default ['title', 'tags', 'categories', 'excerpt']
* @description 搜索的字段
* @see https://fusejs.io/api/options.html#keys
*/
keys: FuseOptions<FuseListItem>['keys']
}
}
/**
* set post default frontmatter
*/
frontmatter: Partial<PostFrontMatter>
/**
* comment: waline/...
*/
comment: {
enable: boolean
}
/**
* third-party plugin need cdn
* aplayer, twikoo
* @default 'https://unpkg.com/'
*/
cdn: {
prefix: string
}
/**
* The license of your posts
* @description 文章所使用的协议,默认使用 Creative Commons
* @default https://creativecommons.org/licenses/
*/
license: {
/**
* Whether to show at the bottom of the article
* @description 是否显示在文章底部
* @default true
*/
enabled: boolean
/**
* Creative License Language, same with your config.lang
* when lang === 'zh-CN', use 'zh'
* @description 默认与站点语言相同
* @default 'en'
*/
language: string
/**
* Type of license
* @description 证书类型
* @default 'by-nc-sa'
*/
type: 'zero' | 'by-sa' | 'by-nd' | 'by-nc' | 'by-nc-sa' | 'by-nc-nd'
}
/**
* donate for author
* @description 打赏/赞助
*/
sponsor: {
enable: boolean
/**
* Donate button title attribute
* @description 打赏按钮的 title 属性
* @default zh:'打赏' en:'Donate'
*/
title?: string
/**
* Donate content description
* @description 打赏的描述内容,在按钮下方所有图片上方,与图片一起折叠
* @default undefined 不显示内容
*/
description?: string
methods: {
name: string
url: string
color: string
icon: string
}[]
}
/**
* image preview by medium-zoom
* @url https://github.com/francoischalifour/medium-zoom
*/
mediumZoom: {
/**
* @zh 启用图片预览
*/
enable: boolean
/**
* For example: '.markdown-body img'
* @default '' content.value querySelectorAll('img')
*/
selector: string | HTMLElement | HTMLElement[]
/**
* @zh 配置项
* @see https://github.com/francoischalifour/medium-zoom#options
*/
options: ZoomOptions
}
/**
* lazyload by vanilla-lazyload and markdown-it-image-figures
* when vanillaLazyLoad.enable is true, imageFigures removeSrc is true, classes is 'lazy'
* @see https://github.com/verlok/vanilla-lazyload
*/
vanillaLazyload: {
enable: boolean
options: ILazyLoadOptions
}
/**
* displayed posts length in every page
* @default 7
*/
pageSize: number
/**
* statistics readingTime and wordCount
* @description 统计阅读时间和字数
*/
statistics: {
enable: boolean
readTime: {
speed: {
/**
* Chinese word count speed
* @description 中文每分钟阅读字数
* @default 300 (300 字/分钟)
*/
cn: number
/**
* English word count speed
* @description 英文每分钟阅读字数
* @default 100 (200 字/分钟)
*/
en: number
}
}
}
/**
* @description Encrypt article
* @description:zh-CN 加密文章
* default algorithm: AES-CBC
*/
encrypt: {
enable: boolean
/**
* [encrypt](https://developer.mozilla.org/zh-CN/docs/Web/API/SubtleCrypto/encrypt#%E6%94%AF%E6%8C%81%E7%9A%84%E7%AE%97%E6%B3%95)
* @default AES-CBC
*/
algorithm: string
iv: Uint8Array
salt: Uint8Array
/**
* @description:zh-CN 全局加密密码 todo
*/
// password: string
}
/**
* @description:en-US Limit the height of the code block in px
* @description:zh-CN 限制代码块的高度,单位是 px
*/
codeHeightLimit?: number
/**
* @description:en-US client redirect rules
* @description:zh-CN 客户端重定向规则
*/
redirects?: {
useVueRouter?: boolean
rules?: RedirectRule[]
}
}
export type PartialDeep<T> = {
[P in keyof T]?: T[P] extends object ? PartialDeep<T[P]> : T[P]
}
/**
* config generated by runtime
*/
export interface RuntimeConfig {
addons: Record<string, ValaxyAddon>
redirects: {
useVueRouter: boolean
redirectRoutes: RouteRecordRaw[]
}
}
export interface Pkg {
name: string
version: string
homepage?: string
[key: string]: any
}
export interface ValaxyConfig<ThemeConfig = DefaultTheme.Config> {
siteConfig: SiteConfig
/**
* The name of theme
* @description 主题名称
*/
theme: string
/**
* The config of theme
* @description 主题配置
*/
themeConfig: ThemeConfig & {
pkg: Pkg
}
/**
* generated by runtime
*/
runtimeConfig: RuntimeConfig
}
/**
* user site config
*/
export type UserSiteConfig = PartialDeep<SiteConfig>
/**
* Valaxy User Config
* @description Valaxy 用户配置
*/
export type UserValaxyConfig<ThemeConfig = DefaultTheme.Config> = PartialDeep<ValaxyConfig<ThemeConfig>>