-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathastro.config.mjs
337 lines (330 loc) · 9.63 KB
/
astro.config.mjs
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
// @ts-check
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';
import fs from 'node:fs';
// Allows changing heading ids
import remarkHeadingId from 'remark-custom-heading-id';
// Makes heading ids auto-create themselves
import { rehypeHeadingIds } from '@astrojs/markdown-remark';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
// Adds support for rendering math
import remarkMath from 'remark-math';
import rehypeKatex from 'rehype-katex';
// Adds links to Web IDE from code blocks
import remarkLinksToWebIDE from './links-to-web-ide';
// Adds syntax highlighting for inline code blocks
import rehypeInlineCodeHighlighting from './inline-code-highlighting';
// Add validation of internal links during production builds
import starlightLinksValidator from 'starlight-links-validator';
// https://astro.build/config
// https://starlight.astro.build/reference/configuration/
export default defineConfig({
outDir: './dist', // default, just to be sure
site: 'https://docs.tact-lang.org',
markdown: {
remarkPlugins: [remarkHeadingId, remarkMath, remarkLinksToWebIDE],
rehypePlugins: [
rehypeHeadingIds,
[rehypeAutolinkHeadings, {
behavior: "append",
properties: {
class: "autolink-header",
ariaHidden: "true",
ariaLabel: "Link to this header",
tabIndex: -1,
},
}],
rehypeInlineCodeHighlighting,
rehypeKatex,
],
},
integrations: [
starlight({
title: {
en: '⚡ Tact Documentation',
'zh-CN': '⚡ Tact 语言文档',
},
titleDelimiter: undefined,
favicon: '/favicon.png',
logo: {
dark: '/public/logo-dark.svg',
light: '/public/logo-light.svg',
alt: '⚡ Tact Documentation',
replacesTitle: true,
},
// 'head' is auto-populated with SEO-friendly contents based on the page frontmatters
head: [
{
// Google tag (gtag.js)
tag: "script",
attrs: { async: true, src: 'https://www.googletagmanager.com/gtag/js?id=G-ZJ3GZHJ0Z5' }
},
{
// Per-page Google tag setup
tag: "script",
content: "window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}gtag('js',new Date());gtag('config','G-ZJ3GZHJ0Z5');",
},
],
social: {
github: 'https://github.com/tact-lang/tact',
telegram: 'https://t.me/tactlang',
"x.com": 'https://x.com/tact_language',
},
editLink: { baseUrl: 'https://github.com/tact-lang/tact/edit/main/docs/' },
tableOfContents: { minHeadingLevel: 2, maxHeadingLevel: 4 },
expressiveCode: {
themes: ['one-dark-pro', 'one-light'],
useStarlightDarkModeSwitch: true,
useStarlightUiThemeColors: true,
shiki: {
langs: [
() => JSON.parse(fs.readFileSync('grammars/grammar-tact.json', 'utf-8')),
() => JSON.parse(fs.readFileSync('grammars/grammar-func.json', 'utf-8')),
() => JSON.parse(fs.readFileSync('grammars/grammar-ohm.json', 'utf-8'))
],
},
},
customCss: [
// To adjust Starlight colors and styles
'./src/starlight.custom.css',
// To properly support KaTeX
'./src/fonts/katex.fontfaces.css',
'./src/katex.min.css',
],
plugins: [starlightLinksValidator({
errorOnFallbackPages: false,
// errorOnInvalidHashes: false,
})],
credits: false,
lastUpdated: true,
disable404Route: false,
// Note, that UI translations are bundled by Starlight for many languages:
// https://starlight.astro.build/guides/i18n/#translate-starlights-ui
//
// Also note, that in order to use fallback content and translation notices
// provided by Starlight, files across language folders must be named the same!
defaultLocale: 'root', // removes language prefix from English pages
locales: {
root: {
label: 'English',
lang: 'en', // lang is required for root locales
},
'zh-cn': {
label: '简体中文',
lang: 'zh-CN',
},
},
// In place of countless meta.js files in old docs:
sidebar: [
{
label: 'Book',
translations: {
'zh-CN': '图书',
},
items: [
{ slug: 'book' },
// {
// label: 'Cheatsheets',
// translations: {
// 'zh-CN': '小抄',
// },
// collapsed: true,
// autogenerate: { directory: 'book/cs' },
// },
{
label: 'Fundamentals of Tact',
translations: { 'zh-CN': 'Tact 语言基础' },
attrs: { class: 'sidebar-separator' },
link: 'book/types#',
},
{ slug: 'book/types' },
{ slug: 'book/integers' },
{ slug: 'book/cells' },
{ slug: 'book/maps' },
{ slug: 'book/structs-and-messages' },
{ slug: 'book/optionals' },
{ slug: 'book/contracts' },
{ slug: 'book/exit-codes' },
{
label: 'Expressiveness',
translations: { 'zh-CN': '表达能力' },
attrs: { class: 'sidebar-separator' },
link: 'book/operators#',
},
{ slug: 'book/operators' },
{ slug: 'book/expressions' },
{ slug: 'book/statements' },
{ slug: 'book/constants' },
{ slug: 'book/functions' },
{ slug: 'book/assembly-functions' },
{
label: 'Communication',
translations: { 'zh-CN': '通信' },
attrs: { class: 'sidebar-separator' },
link: 'book/receive#',
},
{ slug: 'book/receive' },
{ slug: 'book/bounced' },
{ slug: 'book/external' },
{ slug: 'book/lifecycle' },
{ slug: 'book/send' },
{ slug: 'book/message-mode' },
{
label: 'Going places',
translations: { 'zh-CN': '前往各地' },
attrs: { class: 'sidebar-separator' },
link: 'book/compile#',
},
{ slug: 'book/compile' },
{ slug: 'book/debug' },
{ slug: 'book/deploy' },
{ slug: 'book/upgrades' },
{ slug: 'book/import' },
{ slug: 'book/config' },
{ slug: 'book/func' },
{ slug: 'book/security-best-practices' },
],
},
{
label: 'Cookbook',
translations: {
'zh-CN': '食谱',
},
items: [
{ slug: 'cookbook' },
{
label: 'Single contract',
translations: { 'zh-CN': '单一合约' },
attrs: { class: 'sidebar-separator' },
link: 'cookbook/single-communication#',
},
{ slug: 'cookbook/single-communication' },
{ slug: 'cookbook/type-conversion' },
{ slug: 'cookbook/data-structures' },
{ slug: 'cookbook/algo' },
{ slug: 'cookbook/time' },
{ slug: 'cookbook/access' },
{ slug: 'cookbook/random' },
{ slug: 'cookbook/upgrades' },
{ slug: 'cookbook/misc' },
{
label: 'Multiple contracts',
translations: { 'zh-CN': '多重合约' },
attrs: { class: 'sidebar-separator' },
link: 'cookbook/multi-communication#',
},
{ slug: 'cookbook/multi-communication' },
{ slug: 'cookbook/jettons' },
{ slug: 'cookbook/nfts' },
{
label: 'Decentralized EXchanges (DEXes)',
translations: {
'zh-CN': '去中心化交易所(DEXes)',
},
collapsed: true,
autogenerate: { directory: 'cookbook/dexes' }
},
],
},
{
label: 'Reference',
translations: {
'zh-CN': '参考',
},
items: [
{ slug: 'ref' },
{ slug: 'ref/spec' },
{
'label': 'Evolution',
translations: {
'zh-CN': '演变',
},
collapsed: true,
autogenerate: { directory: 'ref/evolution' }
},
{
label: 'Core library',
translations: { 'zh-CN': '核心库' },
attrs: { class: 'sidebar-separator' },
link: 'ref/core-base#',
},
{ slug: 'ref/core-base' },
{ slug: 'ref/core-common' },
{ slug: 'ref/core-comptime' },
{ slug: 'ref/core-debug' },
{ slug: 'ref/core-random' },
{ slug: 'ref/core-math' },
{ slug: 'ref/core-strings' },
{ slug: 'ref/core-cells' },
{ slug: 'ref/core-advanced' },
{
label: 'Standard libraries',
translations: { 'zh-CN': '标准库' },
attrs: { class: 'sidebar-separator' },
link: 'ref/standard-libraries#',
},
{ slug: 'ref/standard-libraries' },
{ slug: 'ref/stdlib-config' },
{ slug: 'ref/stdlib-content' },
{ slug: 'ref/stdlib-deploy' },
{ slug: 'ref/stdlib-dns' },
{ slug: 'ref/stdlib-ownable' },
{ slug: 'ref/stdlib-stoppable' },
],
},
{
label: 'Ecosystem',
translations: {
'zh-CN': '生态系统',
},
items: [
{ slug: 'ecosystem' },
{ slug: 'ecosystem/security-audits' },
{
label: 'Tools',
translations: { 'zh-CN': '工具' },
attrs: { class: 'sidebar-separator' },
link: 'ecosystem/typescript#',
},
{ slug: 'ecosystem/typescript' },
{ slug: 'ecosystem/vscode' },
{ slug: 'ecosystem/jetbrains' },
{ slug: 'ecosystem/misti' },
],
},
{
label: 'Whitepapers',
translations: {
'zh-CN': '白皮书',
},
items: [
{ slug: 'whitepapers' },
{ slug: 'whitepapers/tvm' },
// { slug: 'whitepapers/tblkch' }, // TODO
],
},
{
label: '⭐ Awesome Tact →',
link: 'https://github.com/tact-lang/awesome-tact',
},
{
label: '✈️ Telegram Chat →',
link: 'https://t.me/tactlang',
attrs: { target: '_blank' }
},
{
label: '🐦 X/Twitter →',
link: 'https://twitter.com/tact_language',
attrs: { target: '_blank' }
}
],
}),
],
redirects: {
'/ecosystem/tools/overview': '/ecosystem',
'/ecosystem/tools/typescript': '/ecosystem/typescript',
'/ecosystem/tools/jetbrains': '/ecosystem/jetbrains',
'/ecosystem/tools/vscode': '/ecosystem/vscode',
'/ecosystem/tools/misti': '/ecosystem/misti',
},
});