feat(web): serve v1 docs on opencode.ai/docs and own the zen/go redirects (#62183)

This commit is contained in:
Dax
2026-11-05 16:20:10 -05:00
committed by GitHub
Unverified
parent 504f1ddb26
commit 80bf7f7b0d
6 changed files with 32 additions and 2 deletions
+17 -2
View File
@@ -1,4 +1,4 @@
import { domain } from "./stage"
import { domain, zoneID } from "./stage"
const GITHUB_APP_ID = new sst.Secret("GITHUB_APP_ID")
const GITHUB_APP_PRIVATE_KEY = new sst.Secret("GITHUB_APP_PRIVATE_KEY")
@@ -17,7 +17,7 @@ export const api = new sst.cloudflare.Worker("Api", {
},
})
new sst.cloudflare.x.Astro("Web", {
const web = new sst.cloudflare.x.Astro("Web", {
domain: "docs." + domain,
path: "packages/web",
environment: {
@@ -26,3 +26,18 @@ new sst.cloudflare.x.Astro("Web", {
VITE_API_URL: api.url.apply((url) => url!),
},
})
// The site serves itself under /docs, so these routes take /docs on the main host. `sst dev` deploys no Worker.
const webServer = web.nodes.server
if (webServer) {
for (const [name, pattern] of [
["WebDocsRoute", `${domain}/docs`],
["WebDocsPathRoute", `${domain}/docs/*`],
]) {
new cloudflare.WorkersRoute(name, {
zoneId: zoneID,
pattern,
script: webServer.nodes.worker.scriptName,
})
}
}
+3
View File
@@ -78,6 +78,9 @@ function localeFromAcceptLanguage(header: string | null) {
}
export const onRequest = defineMiddleware((ctx, next) => {
// Moved Zen and Go pages redirect from their own routes, even under a locale alias like /docs/zh/go.
if (/^\/docs\/(?:[^/]+\/)?(zen|go)\/?$/.test(ctx.url.pathname)) return next()
const alias = docsAlias(ctx.url.pathname)
if (alias) {
return redirect(ctx.url, alias.path, alias.locale)
+1
View File
@@ -0,0 +1 @@
export { ALL } from "../go"
+1
View File
@@ -0,0 +1 @@
export { ALL } from "../zen"
+5
View File
@@ -0,0 +1,5 @@
import type { APIRoute } from "astro"
// The Go docs moved to the V2 Console docs, which only exist on the main site, so the target is absolute for
// requests on docs.opencode.ai.
export const ALL: APIRoute = (ctx) => ctx.redirect(new URL("/v2/docs/console/go/", import.meta.env.SITE).href, 302)
+5
View File
@@ -0,0 +1,5 @@
import type { APIRoute } from "astro"
// The Zen docs moved to the V2 Console docs, which only exist on the main site, so the target is absolute for
// requests on docs.opencode.ai.
export const ALL: APIRoute = (ctx) => ctx.redirect(new URL("/v2/docs/console/models/", import.meta.env.SITE).href, 302)