astro.config.mjs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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: ["docs/tui", "docs/cli", "docs/ide", "docs/share", "docs/github", "docs/gitlab"],
  69. },
  70. {
  71. label: "Configure",
  72. items: [
  73. "docs/rules",
  74. "docs/agents",
  75. "docs/models",
  76. "docs/themes",
  77. "docs/keybinds",
  78. "docs/commands",
  79. "docs/formatters",
  80. "docs/permissions",
  81. "docs/lsp",
  82. "docs/mcp-servers",
  83. ],
  84. },
  85. {
  86. label: "Develop",
  87. items: ["docs/sdk", "docs/server", "docs/plugins"],
  88. },
  89. ],
  90. components: {
  91. Hero: "./src/components/Hero.astro",
  92. Head: "./src/components/Head.astro",
  93. Header: "./src/components/Header.astro",
  94. },
  95. plugins: [
  96. theme({
  97. headerLinks: config.headerLinks,
  98. }),
  99. ],
  100. }),
  101. ],
  102. redirects: {
  103. "/discord": "https://discord.gg/opencode",
  104. },
  105. })
  106. function configSchema() {
  107. return {
  108. name: "configSchema",
  109. hooks: {
  110. "astro:build:done": async () => {
  111. console.log("generating config schema")
  112. spawnSync("../opencode/script/schema.ts", ["./dist/config.json"])
  113. },
  114. },
  115. }
  116. }