|
| 1 | +// @ts-check |
| 2 | +import {defineConfig} from "astro/config" |
| 3 | +import starlight from "@astrojs/starlight" |
| 4 | +import starlightThemeRapide from "starlight-theme-rapide" |
| 5 | +import {ExpressiveCodeTheme} from "@astrojs/starlight/expressive-code" |
| 6 | +import fs from "node:fs" |
| 7 | + |
| 8 | +import remarkHeadingId from "remark-custom-heading-id" |
| 9 | + |
| 10 | +import {rehypeHeadingIds} from "@astrojs/markdown-remark" |
| 11 | +import rehypeAutolinkHeadings from "rehype-autolink-headings" |
| 12 | +import starlightLinksValidator from "starlight-links-validator" |
| 13 | + |
| 14 | +import react from "@astrojs/react" |
| 15 | + |
| 16 | +// https://astro.build/config |
| 17 | +// https://starlight.astro.build/reference/configuration/ |
| 18 | +export default defineConfig({ |
| 19 | + outDir: "../dist/spec/doc", |
| 20 | + site: "https://txtracer.ton.org", |
| 21 | + base: "/spec/doc/", |
| 22 | + trailingSlash: "always", |
| 23 | + vite: { |
| 24 | + define: { |
| 25 | + global: "globalThis", |
| 26 | + }, |
| 27 | + optimizeDeps: { |
| 28 | + include: ["buffer", "@ton/core", "@ton/crypto"], |
| 29 | + exclude: ["@ton/tolk-js", "@ton/sandbox"], |
| 30 | + }, |
| 31 | + resolve: { |
| 32 | + alias: { |
| 33 | + buffer: "buffer", |
| 34 | + }, |
| 35 | + }, |
| 36 | + server: { |
| 37 | + fs: { |
| 38 | + allow: [".."], |
| 39 | + }, |
| 40 | + }, |
| 41 | + build: { |
| 42 | + rollupOptions: { |
| 43 | + output: { |
| 44 | + manualChunks: { |
| 45 | + "tolk-runtime": ["@ton/tolk-js", "@ton/sandbox"], |
| 46 | + }, |
| 47 | + }, |
| 48 | + }, |
| 49 | + }, |
| 50 | + }, |
| 51 | + markdown: { |
| 52 | + remarkPlugins: [remarkHeadingId], |
| 53 | + rehypePlugins: [ |
| 54 | + rehypeHeadingIds, |
| 55 | + [ |
| 56 | + rehypeAutolinkHeadings, |
| 57 | + { |
| 58 | + behavior: "append", |
| 59 | + properties: { |
| 60 | + class: "autolink-header", |
| 61 | + ariaHidden: "true", |
| 62 | + ariaLabel: "Link to this header", |
| 63 | + tabIndex: -1, |
| 64 | + }, |
| 65 | + }, |
| 66 | + ], |
| 67 | + ], |
| 68 | + }, |
| 69 | + integrations: [ |
| 70 | + starlight({ |
| 71 | + title: { |
| 72 | + en: "TVM Internals", |
| 73 | + }, |
| 74 | + titleDelimiter: undefined, |
| 75 | + favicon: "/favicon.ico", |
| 76 | + logo: { |
| 77 | + dark: "/public/logo-dark.svg", |
| 78 | + light: "/public/logo-light.svg", |
| 79 | + alt: "TVM Internals", |
| 80 | + replacesTitle: false, |
| 81 | + }, |
| 82 | + // 'head' is auto-populated with SEO-friendly contents based on the page frontmatters |
| 83 | + head: [ |
| 84 | + // { |
| 85 | + // // Google tag (gtag.js) |
| 86 | + // tag: "script", |
| 87 | + // attrs: { |
| 88 | + // async: true, |
| 89 | + // src: "TODO: Add google analytics link", |
| 90 | + // }, |
| 91 | + // }, |
| 92 | + // { |
| 93 | + // // Per-page Google tag setup |
| 94 | + // tag: "script", |
| 95 | + // content: |
| 96 | + // "window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}gtag('js',new Date());gtag('config','G-ZJ3GZHJ0Z5');", |
| 97 | + // }, |
| 98 | + ], |
| 99 | + social: { |
| 100 | + github: "https://github.com/ton-blockchain/txtracer", |
| 101 | + telegram: "https://t.me/toncore", |
| 102 | + }, |
| 103 | + editLink: { |
| 104 | + baseUrl: "https://github.com/ton-blockchain/txtracer/edit/main/spec/src/content/docs/", |
| 105 | + }, |
| 106 | + tableOfContents: {minHeadingLevel: 2, maxHeadingLevel: 4}, |
| 107 | + expressiveCode: { |
| 108 | + themes: [ |
| 109 | + "one-dark-pro", |
| 110 | + ExpressiveCodeTheme.fromJSONString( |
| 111 | + fs.readFileSync(new URL(`./themes/one-light-mod.jsonc`, import.meta.url), "utf-8"), |
| 112 | + ), |
| 113 | + ], |
| 114 | + useStarlightDarkModeSwitch: true, |
| 115 | + useStarlightUiThemeColors: true, |
| 116 | + shiki: { |
| 117 | + langs: [ |
| 118 | + () => JSON.parse(fs.readFileSync("grammars/grammar-func.json", "utf-8")), |
| 119 | + () => JSON.parse(fs.readFileSync("grammars/grammar-tolk.json", "utf-8")), |
| 120 | + () => JSON.parse(fs.readFileSync("grammars/grammar-tlb.json", "utf-8")), |
| 121 | + () => JSON.parse(fs.readFileSync("grammars/grammar-tasm.json", "utf-8")), |
| 122 | + ], |
| 123 | + }, |
| 124 | + }, |
| 125 | + customCss: [ |
| 126 | + // To adjust Starlight colors and styles |
| 127 | + "./src/starlight.custom.css", |
| 128 | + ], |
| 129 | + plugins: [ |
| 130 | + starlightThemeRapide(), |
| 131 | + starlightLinksValidator({ |
| 132 | + errorOnFallbackPages: false, |
| 133 | + errorOnInvalidHashes: false, |
| 134 | + }), |
| 135 | + ], |
| 136 | + credits: false, |
| 137 | + lastUpdated: true, |
| 138 | + disable404Route: false, |
| 139 | + // Note that UI translations are bundled by Starlight for many languages: |
| 140 | + // https://starlight.astro.build/guides/i18n/#translate-starlights-ui |
| 141 | + // |
| 142 | + // To use fallback content and translation notices provided by Starlight, |
| 143 | + // files across language folders must be named the same! |
| 144 | + defaultLocale: "root", |
| 145 | + locales: { |
| 146 | + root: { |
| 147 | + label: "English", |
| 148 | + lang: "en", |
| 149 | + }, |
| 150 | + }, |
| 151 | + sidebar: [ |
| 152 | + { |
| 153 | + label: "Book", |
| 154 | + items: [ |
| 155 | + {slug: "book/basics-register-c0-cc-savelist-if-instruction"}, |
| 156 | + {slug: "book/diving-deeper-exit-points-of-continuations"}, |
| 157 | + {slug: "book/manual-handling-and-jmp-vs-execute"}, |
| 158 | + ], |
| 159 | + }, |
| 160 | + ], |
| 161 | + }), |
| 162 | + react(), |
| 163 | + ], |
| 164 | + redirects: { |
| 165 | + "/": "/spec/doc/book/basics-register-c0-cc-savelist-if-instruction/", |
| 166 | + }, |
| 167 | +}) |
0 commit comments