astro.config.mjs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. output: "server",
  15. adapter: cloudflare({
  16. imageService: "passthrough",
  17. }),
  18. devToolbar: {
  19. enabled: false,
  20. },
  21. server: {
  22. host: "0.0.0.0",
  23. },
  24. markdown: {
  25. rehypePlugins: [rehypeHeadingIds, [rehypeAutolinkHeadings, { behavior: "wrap" }]],
  26. },
  27. build: {},
  28. integrations: [
  29. configSchema(),
  30. solidJs(),
  31. starlight({
  32. title: "opencode",
  33. lastUpdated: true,
  34. expressiveCode: { themes: ["github-light", "github-dark"] },
  35. social: [
  36. { icon: "github", label: "GitHub", href: config.github },
  37. { icon: "discord", label: "Dscord", href: config.discord },
  38. ],
  39. head: [
  40. {
  41. tag: "link",
  42. attrs: {
  43. rel: "icon",
  44. href: "/favicon.svg",
  45. },
  46. },
  47. ],
  48. editLink: {
  49. baseUrl: `${config.github}/edit/dev/packages/web/`,
  50. },
  51. markdown: {
  52. headingLinks: false,
  53. },
  54. customCss: ["./src/styles/custom.css"],
  55. logo: {
  56. light: "./src/assets/logo-light.svg",
  57. dark: "./src/assets/logo-dark.svg",
  58. replacesTitle: true,
  59. },
  60. sidebar: [
  61. "docs",
  62. "docs/config",
  63. "docs/providers",
  64. "docs/enterprise",
  65. "docs/troubleshooting",
  66. {
  67. label: "Usage",
  68. items: [
  69. "docs/tui",
  70. "docs/cli",
  71. "docs/ide",
  72. // "docs/zen",
  73. "docs/share",
  74. "docs/github",
  75. "docs/gitlab"
  76. ],
  77. },
  78. {
  79. label: "Configure",
  80. items: [
  81. "docs/rules",
  82. "docs/agents",
  83. "docs/models",
  84. "docs/themes",
  85. "docs/keybinds",
  86. "docs/commands",
  87. "docs/formatters",
  88. "docs/permissions",
  89. "docs/lsp",
  90. "docs/mcp-servers",
  91. ],
  92. },
  93. {
  94. label: "Develop",
  95. items: ["docs/sdk", "docs/server", "docs/plugins"],
  96. },
  97. ],
  98. components: {
  99. Hero: "./src/components/Hero.astro",
  100. Head: "./src/components/Head.astro",
  101. Header: "./src/components/Header.astro",
  102. },
  103. plugins: [
  104. theme({
  105. headerLinks: config.headerLinks,
  106. }),
  107. ],
  108. }),
  109. ],
  110. redirects: {
  111. "/discord": "https://discord.gg/opencode",
  112. },
  113. })
  114. function configSchema() {
  115. return {
  116. name: "configSchema",
  117. hooks: {
  118. "astro:build:done": async () => {
  119. console.log("generating config schema")
  120. spawnSync("../opencode/script/schema.ts", ["./dist/config.json"])
  121. },
  122. },
  123. }
  124. }