astro.config.mjs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. const github = "https://github.com/sst/opencode"
  12. // https://astro.build/config
  13. export default defineConfig({
  14. site: config.url,
  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. lastUpdated: true,
  35. expressiveCode: { themes: ["github-light", "github-dark"] },
  36. social: [
  37. { icon: "github", label: "GitHub", href: config.github },
  38. { icon: "discord", label: "Dscord", href: config.discord },
  39. ],
  40. head: [
  41. {
  42. tag: "link",
  43. attrs: {
  44. rel: "icon",
  45. href: "/favicon.svg",
  46. },
  47. },
  48. ],
  49. editLink: {
  50. baseUrl: `${github}/edit/dev/packages/web/`,
  51. },
  52. markdown: {
  53. headingLinks: false,
  54. },
  55. customCss: ["./src/styles/custom.css"],
  56. logo: {
  57. light: "./src/assets/logo-light.svg",
  58. dark: "./src/assets/logo-dark.svg",
  59. replacesTitle: true,
  60. },
  61. sidebar: [
  62. "docs",
  63. "docs/config",
  64. "docs/providers",
  65. "docs/enterprise",
  66. "docs/troubleshooting",
  67. {
  68. label: "Usage",
  69. items: ["docs/cli", "docs/ide", "docs/share", "docs/github"],
  70. },
  71. {
  72. label: "Configure",
  73. items: [
  74. "docs/rules",
  75. "docs/agents",
  76. "docs/models",
  77. "docs/themes",
  78. "docs/plugins",
  79. "docs/keybinds",
  80. "docs/formatters",
  81. "docs/permissions",
  82. "docs/lsp",
  83. "docs/mcp-servers",
  84. ],
  85. },
  86. ],
  87. components: {
  88. Hero: "./src/components/Hero.astro",
  89. Head: "./src/components/Head.astro",
  90. Header: "./src/components/Header.astro",
  91. },
  92. plugins: [
  93. theme({
  94. headerLinks: config.headerLinks,
  95. }),
  96. ],
  97. }),
  98. ],
  99. redirects: {
  100. "/discord": "https://discord.gg/opencode",
  101. },
  102. })
  103. function configSchema() {
  104. return {
  105. name: "configSchema",
  106. hooks: {
  107. "astro:build:done": async () => {
  108. console.log("generating config schema")
  109. spawnSync("../opencode/script/schema.ts", ["./dist/config.json"])
  110. },
  111. },
  112. }
  113. }