Commit Graph

3 Commits

Author SHA1 Message Date
YeonGyu-Kim 9848803f4f fix(web): replace next-mdx-remote with marked + raw HTML to avoid CF Workers eval ban
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.
2026-05-08 16:57:28 +09:00
YeonGyu-Kim 57b9d42537 fix(web): bundle docs sources at build time so the worker has no fs
The worker deploy from #3859 returned HTTP 500 on /docs with
`Error: [unenv] fs.readFile is not implemented yet!` (captured via
`wrangler tail`). `loadDocSource` was calling `node:fs/promises`
`readFile` inside an RSC; even though the page is generated as SSG
(`●`), Cloudflare Workers' unenv shim does not implement filesystem
reads, so any code path that reaches the worker (cache miss, prerender
fallback) fails.

Move the read to a prebuild step that emits a TypeScript module:

- `web/scripts/generate-docs-content.mjs` reads each section's source
  from `<repo-root>/docs/` and writes
  `web/lib/docs-content.generated.ts` containing
  `export const DOC_SOURCES: Record<string, string>`.
- `web/scripts/prepare-build.mjs` invokes the generator after the
  cache prune, so every `bun run build` and `bunx opennextjs-cloudflare
  build` regenerates the constant module from the live `docs/`.
- `web/lib/docs-source.ts` now reads `DOC_SOURCES[file]` synchronously
  with no Node I/O.
- `web/app/[locale]/docs/page.tsx` drops the `Promise.all` since reads
  are synchronous.
- `web/.gitignore` excludes the generated file (kept generated, not
  source-of-truth).

Effect: the bundle ships every doc as a string literal. The worker has
no `fs.readFile` call to fail. `docs/` remains the only place an
editor needs to touch.
2026-05-08 16:38:14 +09:00
YeonGyu-Kim f94714bbdf feat(web): import oh-my-openagent-web Next.js + Cloudflare Workers site
Imports the public marketing site previously living in
../oh-my-opencode-web. Independent of the npm plugin: own package.json,
bun.lock, tsconfig.json. Not included in the published package — root
files: array still only ships dist/, bin/, postinstall.mjs.

Stack:
- Next.js 15.5 App Router + RSC, deployed to Cloudflare Workers via
  @opennextjs/cloudflare (build target .open-next/worker.js).
- Tailwind v4 + shadcn/ui primitives.
- next-intl with 4 locales (en/ja/ko/zh) under app/[locale]/.
- Playwright e2e tests under web/e2e/.
- Custom domains ohmyopenagent.com (primary) and ohmyopencode.org
  (legacy alias) declared in web/wrangler.toml.

Source files were re-formatted via `bun run format` to bring them in
line with the existing .prettierrc (singleQuote: false). Functional code
unchanged.
2026-05-08 13:35:00 +09:00