-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathconfig.ts
504 lines (493 loc) · 18.8 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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
import { argv, cwd, env } from 'node:process'
import { BiDirectionalLinks } from '@nolebase/markdown-it-bi-directional-links'
import { UnlazyImages } from '@nolebase/markdown-it-unlazy-img'
import { InlineLinkPreviewElementTransform } from '@nolebase/vitepress-plugin-inline-link-preview/markdown-it'
import { transformHeadMeta } from '@nolebase/vitepress-plugin-meta/vitepress'
import { buildEndGenerateOpenGraphImages } from '@nolebase/vitepress-plugin-og-image/vitepress'
import { transformerTwoslash } from '@shikijs/vitepress-twoslash'
import { gray } from 'colorette'
import MarkdownItFootnote from 'markdown-it-footnote'
import { type DefaultTheme, defineConfig } from 'vitepress'
import packageJSON from '../../package.json'
import { compilerOptions } from './twoslashConfig'
function noTwoslash() {
return argv.some(v => v.includes('vitepress')) && argv.includes('dev')
}
export const sidebars: Record<string, DefaultTheme.Sidebar> = {
'en': {
'/': [
{
text: 'Guides',
items: [
{ text: 'Getting Started', link: '/pages/en/guide/getting-started' },
{ text: 'Recent Updated', link: '/pages/en/recent-updates' },
],
},
{
text: 'Integrations',
items: [
{ text: 'Overview', link: '/pages/en/integrations/' },
],
},
{
text: 'Markdown It Plugins',
items: [
{
text: 'Bi-directional links',
collapsed: true,
items: [
{ text: 'Overview', link: '/pages/en/integrations/markdown-it-bi-directional-links/' },
{ text: 'Getting Started', link: '/pages/en/integrations/markdown-it-bi-directional-links/getting-started' },
{ text: 'Syntax', link: '/pages/en/integrations/markdown-it-bi-directional-links/syntax' },
],
},
{ text: 'Elements Transformation', link: '/pages/en/integrations/markdown-it-element-transform/' },
{ text: 'Lazy loading blurred thumbnails', link: '/pages/en/integrations/markdown-it-unlazy-img/' },
],
},
{
text: 'VitePress Plugins',
items: [
{ text: 'Auto Sidebar', link: '/pages/en/integrations/vitepress-plugin-sidebar/' },
{ text: 'Breadcrumbs', link: '/pages/en/integrations/vitepress-plugin-breadcrumbs/' },
{ text: 'Enhanced Readabilities', link: '/pages/en/integrations/vitepress-plugin-enhanced-readabilities/' },
{ text: 'Index Page', link: '/pages/en/integrations/vitepress-plugin-index/' },
{
text: 'Inline Links Previewing',
collapsed: true,
items: [
{ text: 'Overview', link: '/pages/en/integrations/vitepress-plugin-inline-link-preview/' },
{ text: 'Getting started', link: '/pages/en/integrations/vitepress-plugin-inline-link-preview/getting-started' },
{ text: 'Configuration', link: '/pages/en/integrations/vitepress-plugin-inline-link-preview/configuration' },
],
},
{ text: 'Blinking highlight targeted heading', link: '/pages/en/integrations/vitepress-plugin-highlight-targeted-heading/' },
{
text: 'Git-based page histories',
collapsed: true,
items: [
{ text: 'Overview', link: '/pages/en/integrations/vitepress-plugin-git-changelog/' },
{ text: 'Getting started', link: '/pages/en/integrations/vitepress-plugin-git-changelog/getting-started' },
{ text: 'Configure Vite Plugins', link: '/pages/en/integrations/vitepress-plugin-git-changelog/configure-vite-plugins' },
{ text: 'Configure UI', link: '/pages/en/integrations/vitepress-plugin-git-changelog/configure-ui' },
],
},
{ text: 'Page properties', link: '/pages/en/integrations/vitepress-plugin-page-properties/' },
{ text: 'Page metadata generation', link: '/pages/en/integrations/vitepress-plugin-meta/' },
{ text: 'Previewing image (social media card) generation', link: '/pages/en/integrations/vitepress-plugin-og-image/' },
{ text: 'Enhanced mark elements', link: '/pages/en/integrations/vitepress-plugin-enhanced-mark/' },
{
text: 'Thumbnail hashing for images',
collapsed: true,
items: [
{ text: 'Usage', link: '/pages/en/integrations/vitepress-plugin-thumbnail-hash/' },
{ text: 'Try ThumbHash', link: '/pages/en/integrations/vitepress-plugin-thumbnail-hash/thumbhash' },
],
},
],
},
{
text: 'Obsidian Plugins',
items: [
{ text: 'UnoCSS', link: '/pages/en/integrations/obsidian-plugin-unocss/' },
],
},
{
text: 'UI Components',
items: [
{ text: 'Overview', link: '/pages/en/ui/' },
],
},
{
text: 'Releasing',
items: [
{
text: 'Migration guides',
items: [
{
text: 'Migrate from v1 to v2',
link: '/pages/en/releases/migrations/v1-to-v2',
},
{
text: 'Migrate from v2 to v3',
link: '/pages/en/releases/migrations/v2-to-v3',
},
],
},
],
},
],
'/pages/en/ui/': [
{
text: 'UI Components',
items: [
{ text: 'Overview', link: '/pages/en/ui/' },
],
},
{
text: 'Actions',
items: [
{ text: 'Button', link: '/pages/en/ui/button/' },
],
},
{
text: 'Inputs',
items: [
{ text: 'Radio Group (Horizontal)', link: '/pages/en/ui/input-horizontal-radio-group/' },
{ text: 'Slider', link: '/pages/en/ui/input-slider/' },
],
},
{
text: 'Animations',
items: [
{ text: 'Asciinema player', link: '/pages/en/ui/asciinema-player/' },
{ text: 'Rive Canvas (Lazy Teleport)', link: '/pages/en/ui/lazy-teleport-rive-canvas/' },
],
},
],
},
'zh-CN': {
'/': [
{
text: '指南',
items: [
{ text: '如何开始', link: '/pages/zh-CN/guide/getting-started' },
],
},
{
text: '集成',
items: [
{ text: '概览', link: '/pages/zh-CN/integrations/' },
{ text: '最近更新', link: '/pages/zh-CN/recent-updates' },
],
},
{
text: 'Markdown It 插件',
items: [
{
text: '双向链接',
collapsed: true,
items: [
{ text: '介绍', link: '/pages/zh-CN/integrations/markdown-it-bi-directional-links/' },
{ text: '快速上手', link: '/pages/zh-CN/integrations/markdown-it-bi-directional-links/getting-started' },
{ text: '语法', link: '/pages/zh-CN/integrations/markdown-it-bi-directional-links/syntax' },
],
},
{ text: '元素转换', link: '/pages/zh-CN/integrations/markdown-it-element-transform/' },
{ text: '懒加载模糊缩略图', link: '/pages/zh-CN/integrations/markdown-it-unlazy-img/' },
],
},
{
text: 'VitePress 插件',
items: [
{ text: '自动生成侧边栏', link: '/pages/zh-CN/integrations/vitepress-plugin-sidebar/' },
{ text: '面包屑导航', link: '/pages/zh-CN/integrations/vitepress-plugin-breadcrumbs/' },
{ text: '阅读增强', link: '/pages/zh-CN/integrations/vitepress-plugin-enhanced-readabilities/' },
{ text: '索引页', link: '/pages/zh-CN/integrations/vitepress-plugin-index/' },
{
text: '行内链接预览',
collapsed: true,
items: [
{ text: '介绍', link: '/pages/zh-CN/integrations/vitepress-plugin-inline-link-preview/' },
{ text: '快速上手', link: '/pages/zh-CN/integrations/vitepress-plugin-inline-link-preview/getting-started' },
{ text: '配置', link: '/pages/zh-CN/integrations/vitepress-plugin-inline-link-preview/configuration' },
],
},
{ text: '闪烁高亮当前的目标标题', link: '/pages/zh-CN/integrations/vitepress-plugin-highlight-targeted-heading/' },
{
text: '基于 Git 的页面历史',
collapsed: true,
items: [
{ text: '介绍', link: '/pages/zh-CN/integrations/vitepress-plugin-git-changelog/' },
{ text: '快速上手', link: '/pages/zh-CN/integrations/vitepress-plugin-git-changelog/getting-started' },
{ text: '配置 Vite 插件', link: '/pages/zh-CN/integrations/vitepress-plugin-git-changelog/configure-vite-plugins' },
{ text: '配置 UI 组件', link: '/pages/zh-CN/integrations/vitepress-plugin-git-changelog/configure-ui' },
],
},
{ text: '页面属性', link: '/pages/zh-CN/integrations/vitepress-plugin-page-properties/' },
{ text: '页面元信息生成', link: '/pages/zh-CN/integrations/vitepress-plugin-meta/' },
{ text: '预览图片(社交媒体卡片)生成', link: '/pages/zh-CN/integrations/vitepress-plugin-og-image/' },
{ text: 'mark 元素增强', link: '/pages/zh-CN/integrations/vitepress-plugin-enhanced-mark/' },
{
text: '缩略图模糊哈希生成',
collapsed: true,
items: [
{ text: '用法', link: '/pages/zh-CN/integrations/vitepress-plugin-thumbnail-hash/' },
{ text: '尝试 ThumbHash', link: '/pages/zh-CN/integrations/vitepress-plugin-thumbnail-hash/thumbhash' },
],
},
],
},
{
text: 'Obsidian 插件',
items: [
{ text: 'UnoCSS', link: '/pages/zh-CN/integrations/obsidian-plugin-unocss/' },
],
},
{
text: '版本发布',
items: [
{
text: '迁移指南',
items: [
{
text: '自 v1 迁移至 v2',
link: '/pages/zh-CN/releases/migrations/v1-to-v2',
},
{
text: '自 v2 迁移至 v3',
link: '/pages/zh-CN/releases/migrations/v2-to-v3',
},
],
},
],
},
],
'/pages/zh-CN/ui/': [
{
text: 'UI 组件',
items: [
{ text: '概览', link: '/pages/zh-CN/ui/' },
],
},
{
text: '操作',
items: [
{ text: '按钮', link: '/pages/zh-CN/ui/button/' },
],
},
{
text: '输入',
items: [
{ text: '多个单选(水平)', link: '/pages/zh-CN/ui/input-horizontal-radio-group/' },
{ text: '滑块', link: '/pages/zh-CN/ui/input-slider/' },
],
},
{
text: '动画',
items: [
{ text: 'Asciinema 播放器', link: '/pages/en/ui/asciinema-player/' },
{ text: 'Rive Canvas(懒 Teleport)', link: '/pages/zh-CN/ui/lazy-teleport-rive-canvas/' },
],
},
],
},
}
function getVueProdHydrationMismatchDetailsFlag() {
if (!env) {
console.warn('WARNING: env is not available when trying to get Vue Prod Hydration Mismatch Details Flag')
throw new Error('env is not available')
}
return !!env.VUE_PROD_HYDRATION_MISMATCH_DETAILS_FLAG
}
// https://vitepress.dev/reference/site-config
export default defineConfig({
vite: {
define: {
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: getVueProdHydrationMismatchDetailsFlag(),
},
},
vue: {
template: {
transformAssetUrls: {
video: ['src', 'poster'],
source: ['src'],
img: ['src'],
image: ['xlink:href', 'href'],
use: ['xlink:href', 'href'],
NolebaseUnlazyImg: ['src'],
},
},
},
cleanUrls: true,
ignoreDeadLinks: [
// Site Config | VitePress
// https://vitepress.dev/reference/site-config#ignoredeadlinks
//
// ignore all localhost links
/^https?:\/\/localhost/,
],
head: [
// Proxying Plausible through Netlify | Plausible docs
// https://plausible.io/docs/proxy/guides/netlify
['script', { 'defer': 'true', 'data-domain': 'nolebase-integrations.ayaka.io', 'data-api': '/api/v1/page-external-data/submit', 'src': '/assets/page-external-data/js/script.js' }],
],
themeConfig: {
// Only enable this on debug component style
// externalLinkIcon: true,
outline: 'deep',
socialLinks: [
{ icon: 'github', link: 'https://github.com/nolebase/integrations' },
{ icon: 'discord', link: 'https://discord.gg/XuNFDcDZGj' },
],
search: {
provider: 'local',
options: {
locales: {
'zh-CN': {
translations: {
button: {
buttonText: '搜索文档',
buttonAriaLabel: '搜索文档',
},
modal: {
noResultsText: '无法找到相关结果',
resetButtonTitle: '清除查询条件',
footer: {
selectText: '选择',
navigateText: '切换',
},
},
},
},
},
},
},
},
buildConcurrency: 1000,
locales: {
'root': {
label: 'English',
lang: 'en',
link: '/pages/en/',
title: 'Nólëbase Integrations',
description: 'A collection of diverse documentation engineering tools',
themeConfig: {
nav: [
{
text: 'Guide',
items: [
{ text: 'Getting Started', link: '/pages/en/guide/getting-started' },
{ text: 'Recent Updated', link: '/pages/en/recent-updates' },
],
},
{ text: 'Integrations', link: '/pages/en/integrations/' },
{ text: 'UI Components', link: '/pages/en/ui/' },
{
text: packageJSON.version,
items: [
{
text: 'Migrations',
items: [
{
text: 'Migrate from v1 to v2',
link: '/pages/en/releases/migrations/v1-to-v2',
},
{
text: 'Migrate from v2 to v3',
link: '/pages/en/releases/migrations/v2-to-v3',
},
],
},
],
},
],
sidebar: sidebars.en,
},
},
'zh-CN': {
label: '简体中文',
lang: 'zh-CN',
link: '/pages/zh-CN/',
title: 'Nólëbase 集成',
description: '多元化的文档工程工具合集',
themeConfig: {
nav: [
{
text: '指南',
items: [
{ text: '快速开始', link: '/pages/zh-CN/guide/getting-started' },
{ text: '最近更新', link: '/pages/zh-CN/recent-updates' },
],
},
{ text: '集成', link: '/pages/zh-CN/integrations/' },
{ text: 'UI 组件', link: '/pages/zh-CN/ui/' },
{
text: packageJSON.version,
items: [
{
text: '迁移指南',
items: [
{
text: '自 v1 迁移至 v2',
link: '/pages/zh-CN/releases/migrations/v1-to-v2',
},
{
text: '自 v2 迁移至 v3',
link: '/pages/zh-CN/releases/migrations/v2-to-v3',
},
],
},
],
},
],
sidebar: sidebars['zh-CN'],
},
},
},
markdown: {
codeTransformers: noTwoslash()
? []
: [
transformerTwoslash({
errorRendering: 'hover',
onTwoslashError(error, _, __, ___) {
console.error('Twoslash Error:', (error as Error)?.message, '\n', (error as Error)?.stack ? gray(String((error as Error)?.stack)) : '')
},
twoslashOptions: compilerOptions,
}),
],
preConfig(md) {
md.use(BiDirectionalLinks({
dir: cwd(),
}))
md.use(UnlazyImages(), {
imgElementTag: 'NolebaseUnlazyImg',
})
},
config(md) {
md.use(MarkdownItFootnote)
md.use(InlineLinkPreviewElementTransform)
},
},
async transformHead(context) {
let head = [...context.head]
const returnedHead = await transformHeadMeta()(head, context)
if (typeof returnedHead !== 'undefined')
head = returnedHead
return head
},
async buildEnd(siteConfig) {
const newBuilder = buildEndGenerateOpenGraphImages({
baseUrl: 'https://nolebase-integrations.ayaka.io',
category: {
byPathPrefix: [
{ prefix: '/pages/en/integrations/markdown-it-bi-directional-links', text: 'Markdown It Plugins: Bi-directional links' },
{ prefix: '/pages/en/integrations/markdown-it', text: 'Markdown It Plugins' },
{ prefix: '/pages/en/integrations/obsidian-plugin', text: 'Obsidian Plugins' },
{ prefix: '/pages/en/integrations/vitepress-plugin-inline-link-preview', text: 'VitePress Plugin: Inline Links Previewing' },
{ prefix: '/pages/en/integrations/vitepress-plugin-git-changelog', text: 'VitePress Plugin: Git-based page histories' },
{ prefix: '/pages/en/integrations/vitepress-plugin-thumbnail-hash', text: 'VitePress Plugin: Thumbnail hashing for images' },
{ prefix: '/pages/en/integrations/vitepress-plugin', text: 'VitePress Plugins' },
{ prefix: '/pages/en/integrations/', text: 'Integrations' },
{ prefix: '/pages/en/guide/', text: 'Guide' },
{ prefix: '/pages/en/ui/', text: 'UI Components' },
{ prefix: '/pages/en/', text: 'Documentations' },
{ prefix: '/pages/zh-CN/integrations/markdown-it-bi-directional-links', text: 'Markdown It 插件:双向链接' },
{ prefix: '/pages/zh-CN/integrations/markdown-it', text: 'Markdown It 插件' },
{ prefix: '/pages/zh-CN/integrations/obsidian-plugin', text: 'Obsidian 插件' },
{ prefix: '/pages/zh-CN/integrations/vitepress-plugin-inline-link-preview', text: 'VitePress 插件:行内链接预览' },
{ prefix: '/pages/zh-CN/integrations/vitepress-plugin-git-changelog', text: 'VitePress 插件:变更日志 及 文件历史' },
{ prefix: '/pages/zh-CN/integrations/vitepress-plugin-thumbnail-hash', text: 'VitePress 插件:缩略图模糊哈希生成' },
{ prefix: '/pages/zh-CN/integrations/vitepress-plugin', text: 'VitePress 插件' },
{ prefix: '/pages/zh-CN/integrations/', text: '集成' },
{ prefix: '/pages/zh-CN/guide/', text: '指南' },
{ prefix: '/pages/zh-CN/ui/', text: 'UI 组件' },
{ prefix: '/pages/zh-CN/', text: '文档' },
],
fallbackWithFrontmatter: true,
},
})
await newBuilder(siteConfig)
},
})