-
Notifications
You must be signed in to change notification settings - Fork 93
/
config.ts
705 lines (700 loc) · 21.9 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
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
import { defineUserConfig } from "vuepress-vite";
import type { DefaultThemeOptions } from "vuepress-vite";
export default defineUserConfig<DefaultThemeOptions>({
title: "grammY",
description: "The Telegram Bot Framework.",
locales: {
"/": {
lang: "en-US",
title: "grammY",
description: "The Telegram Bot Framework.",
},
"/zh/": {
lang: "zh-CN",
title: "grammY",
description: "Telegram Bot 框架",
},
},
shouldPrefetch: true,
themeConfig: {
logo: "/Y.png",
locales: {
"/": {
selectLanguageName: "English",
editLinkText: "Edit this page on GitHub",
notFound: [
"Not Found",
"Nope.",
"nothin' here for ya, sorry",
"Error 404/ This Page Could Not Be Found But/ A Haiku Instead",
"Country rooooaaaads,",
],
backToHome: "Take me hoooooooome",
navbar: [
{ text: "Guide", link: "/guide/" },
{
text: "Learn",
children: [
{
text: "Guide",
children: [
{
text: "Overview",
link: "/guide/README.md",
},
{
text: "Introduction",
link: "/guide/introduction.md",
},
{
text: "Getting started",
link: "/guide/getting-started.md",
},
{
text: "Sending and receiving messages",
link: "/guide/basics.md",
},
{
text: "Context",
link: "/guide/context.md",
},
{
text: "Bot API",
link: "/guide/api.md",
},
{
text: "Filter queries and bot.on()",
link: "/guide/filter-queries.md",
},
{
text: "Commands",
link: "/guide/commands.md",
},
{
text: "Middleware",
link: "/guide/middleware.md",
},
{
text: "Error handling",
link: "/guide/errors.md",
},
{
text: "Inline Queries",
link: "/guide/inline-queries.md",
},
{
text: "File handling",
link: "/guide/files.md",
},
{
text: "Games",
link: "/guide/games.md",
},
{
text: "Long Polling vs. Webhooks",
link: "/guide/deployment-types.md",
},
],
},
{
text: "Advanced",
children: [
{
text: "Overview",
link: "/advanced/README.md",
},
{
text: "Middleware redux",
link: "/advanced/middleware.md",
},
{
text: "Scaling Up I: Large codebase",
link: "/advanced/structuring.md",
},
{
text: "Scaling Up II: High load",
link: "/advanced/scaling.md",
},
{
text: "Scaling Up III: Reliability",
link: "/advanced/reliability.md",
},
{
text: "Scaling Up IV: Flood Limits",
link: "/advanced/flood.md",
},
{
text: "Bot API Transformers",
link: "/advanced/transformers.md",
},
{
text: "Proxy Support",
link: "/advanced/proxy.md",
},
{
text: "Deployment Checklist",
link: "/advanced/deployment.md",
},
],
},
],
},
{
text: "Plugins",
children: [
{
text: "Introduction",
children: [
{
text: "About Plugins",
link: "/plugins/README.md",
},
],
},
{
text: "Official",
children: [
{
text: "Sessions and storing data (built-in)",
link: "/plugins/session.md",
},
{
text: "Keyboards and Inline Keyboards (built-in)",
link: "/plugins/keyboard.md",
},
{
text: "Interactive menus (menu)",
link: "/plugins/menu.md",
},
{
text: "Stateless Question (stateless-question)",
link: "/plugins/stateless-question.md",
},
{
text: "Concurrency (runner)",
link: "/plugins/runner.md",
},
{
text: "Hydration (hydrate)",
link: "/plugins/hydrate.md",
},
{
text: "Retry API requests (auto-retry)",
link: "/plugins/auto-retry.md",
},
{
text: "Flood control (transformer-throttler)",
link: "/plugins/transformer-throttler.md",
},
{
text: "Rate limit users (ratelimiter)",
link: "/plugins/ratelimiter.md",
},
{
text: "Files (files)",
link: "/plugins/files.md",
},
{
text: "Internationalization (i18n)",
link: "/plugins/i18n.md",
},
{
text: "Router (router)",
link: "/plugins/router.md",
},
{
text: "Parse Mode (parse-mode)",
link: "/plugins/parse-mode.md",
},
{
text: "Command filtering (command-fiter)",
link: "/plugins/command-filter.md",
},
],
},
{
text: "Third-party",
children: [
{
text: "Console time",
link: "/plugins/console-time.md",
},
{
text: "[Submit your PR!]",
link:
"/plugins/README.md#submitting-your-own-package-to-the-docs",
},
],
},
],
},
{
text: "Examples",
children: [
{
text: "Examples",
children: [
{
text: "Example Bots Repository",
link: "https://github.com/grammyjs/examples",
},
{
text: "Live Browser Demo",
link: "/demo/README.md",
},
{ text: "Example Bots", link: "/demo/examples.md" },
{
text: "Community Showlounge",
link: "/demo/showlounge.md",
},
],
},
],
},
{
text: "Resources",
children: [
{
text: "grammY",
children: [
{
text: "Community Chat",
link: "https://t.me/grammyjs",
},
{
text: "Awesome grammY",
link: "https://github.com/grammyjs/awesome-grammY",
},
{
text: "News",
link: "https://t.me/grammyjs_news",
},
{
text: "FAQ",
link: "/resources/faq.md",
},
{
text: "Comparison to other frameworks",
link: "/resources/comparison.md",
},
],
},
{
text: "Telegram",
children: [
{
text: "Introduction for Developers",
link: "https://core.telegram.org/bots",
},
{
text: "Bots FAQ",
link: "https://core.telegram.org/bots/faq",
},
{
text: "Bot API Reference",
link: "https://core.telegram.org/bots/api",
},
],
},
{
text: "Hosting",
children: [
{
text: "Heroku",
link: "/hosting/heroku.md",
},
{
text: "Google Cloud Functions",
link: "/hosting/gcf.md",
},
],
},
],
},
{
text: "API Reference",
link: "https://doc.deno.land/https/deno.land/x/grammy/mod.ts",
},
],
},
"/zh/": {
selectLanguageText: "语言",
selectLanguageName: "简体中文",
editLinks: true,
editLinkText: "在 GitHub 上编辑此页!",
contributorsText: "贡献者",
lastUpdatedText: "最近更新时间",
notFound: [
"糟糕!这个页面不存在。",
"无",
"抱歉,这里还不存在内容。",
"Error 404/ 页面不存在,但一只小可爱替代了他~",
"回家吧,回到最初的美好。",
],
backToHome: "回到首页",
navbar: [
{ text: "基础", link: "/zh/guide/" },
{
text: "了解",
children: [
{
text: "基础",
children: [
{
text: "概述",
link: "/zh/guide/README.md",
},
{
text: "简介",
link: "/zh/guide/introduction.md",
},
{
text: "入门",
link: "/zh/guide/getting-started.md",
},
{
text: "发送和接收消息",
link: "/zh/guide/basics.md",
},
{
text: "上下文",
link: "/zh/guide/context.md",
},
{
text: "Bot API",
link: "/zh/guide/api.md",
},
{
text: "Filter 查询与 bot.on()",
link: "/zh/guide/filter-queries.md",
},
{
text: "Commands",
link: "/zh/guide/commands.md",
},
{
text: "中间件",
link: "/zh/guide/middleware.md",
},
{
text: "错误捕获",
link: "/zh/guide/errors.md",
},
{
text: "内联查询",
link: "/zh/guide/inline-queries.md",
},
{
text: "文件管理",
link: "/zh/guide/files.md",
},
{
text: "游戏",
link: "/zh/guide/games.md",
},
{
text: "长轮询 vs. Webhooks",
link: "/zh/guide/deployment-types.md",
},
],
},
{
text: "进阶",
children: [
{
text: "概述",
link: "/zh/advanced/README.md",
},
{
text: "重构中间件",
link: "/zh/advanced/middleware.md",
},
{
text: "I: 代码组织",
link: "/zh/advanced/structuring.md",
},
{
text: "II: 高负载",
link: "/zh/advanced/scaling.md",
},
{
text: "III: 可靠性",
link: "/zh/advanced/reliability.md",
},
{
text: "IV: 极限控制",
link: "/zh/advanced/flood.md",
},
{
text: "可定制的 Bot API",
link: "/zh/advanced/transformers.md",
},
{
text: "代理支持",
link: "/zh/advanced/proxy.md",
},
{
text: "部署",
link: "/zh/advanced/deployment.md",
},
],
},
],
},
{
text: "插件",
children: [
{
text: "简介",
children: [
{
text: "关于插件",
link: "/zh/plugins/README.md",
},
],
},
{
text: "官方维护",
children: [
{
text: "会话与数据储存(内置)",
link: "/zh/plugins/session.md",
},
{
text: "Keyboards 与 Inline Keyboards(内置)",
link: "/zh/plugins/keyboard.md",
},
{
text: "互动菜单(menu)",
link: "/zh/plugins/menu.md",
},
{
text: "无状态问题 (stateless-question)",
link: "/zh/plugins/stateless-question.md",
},
{
text: "并发 (runner)",
link: "/zh/plugins/runner.md",
},
{
text: "Hydration (hydrate)",
link: "/zh/plugins/hydrate.md",
},
{
text: "可重试的 API 请求 (auto-retry)",
link: "/zh/plugins/auto-retry.md",
},
{
text: "顶峰控制 (transformer-throttler)",
link: "/zh/plugins/transformer-throttler.md",
},
{
text: "用户守卫 (ratelimiter)",
link: "/zh/plugins/ratelimiter.md",
},
{
text: "文件助手 (files)",
link: "/zh/plugins/files.md",
},
{
text: "国际化 (i18n)",
link: "/zh/plugins/i18n.md",
},
{
text: "路由 (router)",
link: "/zh/plugins/router.md",
},
{
text: "解析模式 (parse-mode)",
link: "/zh/plugins/parse-mode.md",
},
{
text: "指令过滤 (command-fiter)",
link: "/zh/plugins/command-filter.md",
},
],
},
{
text: "第三方",
children: [
{
text: "Console time",
link: "/zh/plugins/console-time.md",
},
{
text: "[等待你的 PR!]",
link:
"/plugins/README.md#submitting-your-own-package-to-the-docs",
},
],
},
],
},
{
text: "示例",
children: [
{
text: "示例",
children: [
{
text: "示例 Bots 仓库",
link: "/zh/ttps://github.com/grammyjs/examples",
},
{
text: "在线 Demo",
link: "/zh/demo/README.md",
},
{
text: "示例 Bots",
link: "/zh/demo/examples.md",
},
{
text: "社区示例",
link: "/zh/demo/showlounge.md",
},
],
},
],
},
{
text: "资源",
children: [
{
text: "grammY",
children: [
{
text: "社区聊天",
link: "/zh/ttps://t.me/grammyjs",
},
{
text: "Awesome grammY",
link: "/zh/ttps://github.com/grammyjs/awesome-grammY",
},
{
text: "咨询",
link: "/zh/ttps://t.me/grammyjs_news",
},
{
text: "FAQ",
link: "/zh/resources/faq.md",
},
{
text: "与其他框架的比较",
link: "/zh/resources/comparison.md",
},
],
},
{
text: "TODO translate Telegram",
children: [
{
text: "面向开发者的介绍",
link: "/zh/ttps://core.telegram.org/bots",
},
{
text: "Bots FAQ",
link: "/zh/ttps://core.telegram.org/bots/faq",
},
{
text: "Bot API 概览",
link: "/zh/ttps://core.telegram.org/bots/api",
},
],
},
{
text: "托管服务",
children: [
{
text: "Heroku",
link: "/zh/hosting/heroku.md",
},
{
text: "Google Cloud Functions",
link: "/zh/hosting/gcf.md",
},
],
},
],
},
{
text: "API 参考",
link: "https://doc.deno.land/https/deno.land/x/grammy/mod.ts",
},
],
},
},
repo: "https://github.com/grammyjs/grammY",
docsRepo: "https://github.com/grammyjs/website",
docsDir: "site/docs",
docsBranch: "main",
editLink: true,
editLinkPattern: ":repo/edit/:branch/:path",
repoLabel: "GitHub",
},
plugins: [
[
"@vuepress/plugin-docsearch",
{
apiKey: "17b3527aa6f36e8d3fe2276b0f4d9633",
indexName: "grammy",
placeholder: "Search",
locales: { "/zh/": { placeholder: "搜索文档" } },
sitemaps: ["https://grammy.dev/sitemap.xml"],
},
],
[
{
name: "break-long-inline-code-snippets",
extendsMarkdown: (md) => {
md.renderer.rules.code_inline = (
tokens,
idx,
_opts,
_env,
slf,
) => {
const token = tokens[idx];
const attributes = slf.renderAttrs(token);
const withBreaks = insertWbrTags(token.content);
const escaped = escapeHtml(withBreaks);
return `<code${attributes}>${escaped}</code>`;
};
},
},
],
],
});
// Adapted from original `code_inline` implementation of markdown-it
const HTML_ESCAPE_TEST_RE = /&|<(?!wbr>)|(?<!<wbr)>/;
const HTML_ESCAPE_REPLACE_RE = /&|<(?!wbr>)|(?<!<wbr)>/g;
const HTML_REPLACEMENTS = {
"&": "&",
"<": "<",
">": ">",
'"': """,
};
function replaceUnsafeChar(ch: string) {
return HTML_REPLACEMENTS[ch];
}
function escapeHtml(str: string) {
return HTML_ESCAPE_TEST_RE.test(str)
? str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar)
: str;
}
function insertWbrTags(url: string) {
// Adapted from https://css-tricks.com/better-line-breaks-for-long-urls/
return url
.split("//")
.map(
(str) =>
str
// Insert a word break opportunity after a colon
.replace(/(?<after>:)/giu, "$1<wbr>")
// Before a single slash, tilde, period, comma, hyphen, underline, question mark, number sign, or percent symbol
.replace(/(?<before>[/~.,\-_?#%])/giu, "<wbr>$1")
// Before and after an equals sign or ampersand
.replace(/(?<beforeAndAfter>[=&])/giu, "<wbr>$1<wbr>"),
)
// Reconnect the strings with word break opportunities after double slashes
.join("//<wbr>");
}