9848803f4f
The /docs deploy from #3860 still returned HTTP 500 with `EvalError: Code generation from strings disallowed for this context` (captured via `wrangler tail`). `next-mdx-remote/rsc` compiles MDX to JSX *at runtime* using `new Function()` style code generation. Cloudflare Workers' security sandbox bans all dynamic code generation from strings, even from inside trusted code, so any worker invocation that touched the docs page threw immediately. Switch to a build-time markdown -> HTML pipeline: - Drop `next-mdx-remote` and `gray-matter`. Add `marked` (pure-JS, no eval). - `web/scripts/generate-docs-content.mjs` now runs each markdown source through `marked.parse()` (gfm enabled) at build time and writes the resulting HTML strings into `web/lib/docs-content.generated.ts`. - `web/app/[locale]/docs/page.tsx` renders each section as `<article className="docs-content" dangerouslySetInnerHTML={{ __html: section.html }} />`. No MDX runtime, no JSX compilation at request time, just static HTML injection. - `web/app/globals.css` adds a `@layer components` block targeting `.docs-content h1..h4, p, a, ul, ol, li, blockquote, code, pre, table, thead, th, td, hr, strong`. Same shadcn-themed look that the dropped `mdx-components.tsx` provided, applied via CSS instead of React component overrides. - `web/components/docs/mdx-components.tsx` removed. We lose MDX features (JSX inside markdown), but the docs are pure markdown anyway. `docs/` remains the SoT; the marketing site renders identical content with no eval and no fs at runtime.
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import { readFile, writeFile } from "node:fs/promises"
|
|
import path from "node:path"
|
|
import { Marked } from "marked"
|
|
|
|
const SECTIONS = [
|
|
{ file: "guide/overview.md" },
|
|
{ file: "guide/installation.md" },
|
|
{ file: "guide/orchestration.md" },
|
|
{ file: "guide/agent-model-matching.md" },
|
|
{ file: "guide/team-mode.md" },
|
|
{ file: "reference/cli.md" },
|
|
{ file: "reference/configuration.md" },
|
|
{ file: "reference/features.md" },
|
|
{ file: "manifesto.md" },
|
|
]
|
|
|
|
const DOCS_ROOT = path.resolve(process.cwd(), "..", "docs")
|
|
const OUTPUT = path.resolve(process.cwd(), "lib", "docs-content.generated.ts")
|
|
|
|
const marked = new Marked({ gfm: true, breaks: false })
|
|
|
|
const sources = {}
|
|
for (const s of SECTIONS) {
|
|
const md = await readFile(path.join(DOCS_ROOT, s.file), "utf8")
|
|
sources[s.file] = await marked.parse(md)
|
|
}
|
|
|
|
const out =
|
|
"// Generated by scripts/generate-docs-content.mjs - DO NOT EDIT\n" +
|
|
"export const DOC_SOURCES: Record<string, string> = " +
|
|
JSON.stringify(sources, null, 2) +
|
|
"\n"
|
|
|
|
await writeFile(OUTPUT, out)
|
|
console.log("Generated " + OUTPUT + " with " + SECTIONS.length + " HTML-compiled docs")
|