astro.config.mjs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. // @ts-check
  2. import { defineConfig } from "astro/config"
  3. import starlight from "@astrojs/starlight"
  4. import solidJs from "@astrojs/solid-js"
  5. import cloudflare from "@astrojs/cloudflare"
  6. import theme from "toolbeam-docs-theme"
  7. import config from "./config.mjs"
  8. import { rehypeHeadingIds } from "@astrojs/markdown-remark"
  9. import rehypeAutolinkHeadings from "rehype-autolink-headings"
  10. import { spawnSync } from "child_process"
  11. // https://astro.build/config
  12. export default defineConfig({
  13. site: config.url,
  14. base: "/docs",
  15. output: "server",
  16. adapter: cloudflare({
  17. imageService: "passthrough",
  18. }),
  19. devToolbar: {
  20. enabled: false,
  21. },
  22. server: {
  23. host: "0.0.0.0",
  24. },
  25. markdown: {
  26. rehypePlugins: [rehypeHeadingIds, [rehypeAutolinkHeadings, { behavior: "wrap" }]],
  27. },
  28. build: {},
  29. integrations: [
  30. configSchema(),
  31. solidJs(),
  32. starlight({
  33. title: "OpenCode",
  34. defaultLocale: "root",
  35. locales: {
  36. root: {
  37. label: "English",
  38. lang: "en",
  39. dir: "ltr",
  40. },
  41. ar: {
  42. label: "العربية",
  43. lang: "ar",
  44. dir: "rtl",
  45. },
  46. bs: {
  47. label: "Bosanski",
  48. lang: "bs-BA",
  49. dir: "ltr",
  50. },
  51. da: {
  52. label: "Dansk",
  53. lang: "da-DK",
  54. dir: "ltr",
  55. },
  56. de: {
  57. label: "Deutsch",
  58. lang: "de-DE",
  59. dir: "ltr",
  60. },
  61. es: {
  62. label: "Espa\u00f1ol",
  63. lang: "es-ES",
  64. dir: "ltr",
  65. },
  66. fr: {
  67. label: "Fran\u00e7ais",
  68. lang: "fr-FR",
  69. dir: "ltr",
  70. },
  71. it: {
  72. label: "Italiano",
  73. lang: "it-IT",
  74. dir: "ltr",
  75. },
  76. ja: {
  77. label: "日本語",
  78. lang: "ja-JP",
  79. dir: "ltr",
  80. },
  81. ko: {
  82. label: "한국어",
  83. lang: "ko-KR",
  84. dir: "ltr",
  85. },
  86. nb: {
  87. label: "Norsk Bokm\u00e5l",
  88. lang: "nb-NO",
  89. dir: "ltr",
  90. },
  91. pl: {
  92. label: "Polski",
  93. lang: "pl-PL",
  94. dir: "ltr",
  95. },
  96. "pt-br": {
  97. label: "Portugu\u00eas (Brasil)",
  98. lang: "pt-BR",
  99. dir: "ltr",
  100. },
  101. ru: {
  102. label: "Русский",
  103. lang: "ru-RU",
  104. dir: "ltr",
  105. },
  106. th: {
  107. label: "ไทย",
  108. lang: "th-TH",
  109. dir: "ltr",
  110. },
  111. tr: {
  112. label: "T\u00fcrk\u00e7e",
  113. lang: "tr-TR",
  114. dir: "ltr",
  115. },
  116. "zh-cn": {
  117. label: "简体中文",
  118. lang: "zh-CN",
  119. dir: "ltr",
  120. },
  121. "zh-tw": {
  122. label: "繁體中文",
  123. lang: "zh-TW",
  124. dir: "ltr",
  125. },
  126. },
  127. favicon: "/favicon-v3.svg",
  128. head: [
  129. {
  130. tag: "link",
  131. attrs: {
  132. rel: "icon",
  133. href: "/favicon-v3.ico",
  134. sizes: "32x32",
  135. },
  136. },
  137. {
  138. tag: "link",
  139. attrs: {
  140. rel: "icon",
  141. type: "image/png",
  142. href: "/favicon-96x96-v3.png",
  143. sizes: "96x96",
  144. },
  145. },
  146. {
  147. tag: "link",
  148. attrs: {
  149. rel: "apple-touch-icon",
  150. href: "/apple-touch-icon-v3.png",
  151. sizes: "180x180",
  152. },
  153. },
  154. ],
  155. lastUpdated: true,
  156. expressiveCode: { themes: ["github-light", "github-dark"] },
  157. social: [
  158. { icon: "github", label: "GitHub", href: config.github },
  159. { icon: "discord", label: "Discord", href: config.discord },
  160. ],
  161. editLink: {
  162. baseUrl: `${config.github}/edit/dev/packages/web/`,
  163. },
  164. markdown: {
  165. headingLinks: false,
  166. },
  167. customCss: ["./src/styles/custom.css"],
  168. logo: {
  169. light: "./src/assets/logo-light.svg",
  170. dark: "./src/assets/logo-dark.svg",
  171. replacesTitle: true,
  172. },
  173. sidebar: [
  174. "",
  175. "config",
  176. "providers",
  177. "network",
  178. "enterprise",
  179. "troubleshooting",
  180. "windows-wsl",
  181. "1-0",
  182. {
  183. label: "Usage",
  184. translations: {
  185. en: "Usage",
  186. ar: "الاستخدام",
  187. "bs-BA": "Korištenje",
  188. "da-DK": "Brug",
  189. "de-DE": "Nutzung",
  190. "es-ES": "Uso",
  191. "fr-FR": "Utilisation",
  192. "it-IT": "Utilizzo",
  193. "ja-JP": "使い方",
  194. "ko-KR": "사용",
  195. "nb-NO": "Bruk",
  196. "pl-PL": "Użycie",
  197. "pt-BR": "Uso",
  198. "ru-RU": "Использование",
  199. "th-TH": "การใช้งาน",
  200. "tr-TR": "Kullanım",
  201. "zh-CN": "使用",
  202. "zh-TW": "使用",
  203. },
  204. items: ["tui", "cli", "web", "ide", "zen", "share", "github", "gitlab"],
  205. },
  206. {
  207. label: "Configure",
  208. translations: {
  209. en: "Configure",
  210. ar: "الإعداد",
  211. "bs-BA": "Podešavanje",
  212. "da-DK": "Konfiguration",
  213. "de-DE": "Konfiguration",
  214. "es-ES": "Configuración",
  215. "fr-FR": "Configuration",
  216. "it-IT": "Configurazione",
  217. "ja-JP": "設定",
  218. "ko-KR": "구성",
  219. "nb-NO": "Konfigurasjon",
  220. "pl-PL": "Konfiguracja",
  221. "pt-BR": "Configuração",
  222. "ru-RU": "Настройка",
  223. "th-TH": "การกำหนดค่า",
  224. "tr-TR": "Yapılandırma",
  225. "zh-CN": "配置",
  226. "zh-TW": "設定",
  227. },
  228. items: [
  229. "tools",
  230. "rules",
  231. "agents",
  232. "models",
  233. "themes",
  234. "keybinds",
  235. "commands",
  236. "formatters",
  237. "permissions",
  238. "lsp",
  239. "mcp-servers",
  240. "acp",
  241. "skills",
  242. "custom-tools",
  243. ],
  244. },
  245. {
  246. label: "Develop",
  247. translations: {
  248. en: "Develop",
  249. ar: "التطوير",
  250. "bs-BA": "Razvoj",
  251. "da-DK": "Udvikling",
  252. "de-DE": "Entwicklung",
  253. "es-ES": "Desarrollo",
  254. "fr-FR": "Développement",
  255. "it-IT": "Sviluppo",
  256. "ja-JP": "開発",
  257. "ko-KR": "개발",
  258. "nb-NO": "Utvikling",
  259. "pl-PL": "Rozwój",
  260. "pt-BR": "Desenvolvimento",
  261. "ru-RU": "Разработка",
  262. "th-TH": "การพัฒนา",
  263. "tr-TR": "Geliştirme",
  264. "zh-CN": "开发",
  265. "zh-TW": "開發",
  266. },
  267. items: ["sdk", "server", "plugins", "ecosystem"],
  268. },
  269. ],
  270. components: {
  271. Hero: "./src/components/Hero.astro",
  272. Head: "./src/components/Head.astro",
  273. Header: "./src/components/Header.astro",
  274. Footer: "./src/components/Footer.astro",
  275. SiteTitle: "./src/components/SiteTitle.astro",
  276. },
  277. plugins: [
  278. theme({
  279. headerLinks: config.headerLinks,
  280. }),
  281. ],
  282. }),
  283. ],
  284. })
  285. function configSchema() {
  286. return {
  287. name: "configSchema",
  288. hooks: {
  289. "astro:build:done": async () => {
  290. console.log("generating config schema")
  291. spawnSync("../opencode/script/schema.ts", ["./dist/config.json"])
  292. },
  293. },
  294. }
  295. }