diff --git a/apps/web/src/app/opengraph-image.tsx b/apps/web/src/app/opengraph-image.tsx index b4325d0b..d636faea 100644 --- a/apps/web/src/app/opengraph-image.tsx +++ b/apps/web/src/app/opengraph-image.tsx @@ -1,4 +1,6 @@ import { ImageResponse } from 'next/og' +import { renderToStaticMarkup } from 'react-dom/server' +import { AbacusReact } from '@soroban/abacus-react' // Route segment config export const runtime = 'edge' @@ -11,10 +13,47 @@ export const size = { } export const contentType = 'image/png' +// Extract just the SVG element content from rendered output +function extractSvgContent(markup: string): string { + const svgMatch = markup.match(/]*>([\s\S]*?)<\/svg>/) + if (!svgMatch) { + throw new Error('No SVG element found in rendered output') + } + return svgMatch[1] +} + // Image generation -// Note: Using simplified abacus HTML/CSS representation instead of StaticAbacus -// because ImageResponse has limited JSX support (no custom components) +// Note: Now using AbacusReact server-side rendering, same as icon.svg and og-image.svg export default async function Image() { + // Render AbacusReact server-side + const abacusMarkup = renderToStaticMarkup( + + ) + + // Extract SVG content + const svgContent = extractSvgContent(abacusMarkup) + return new ImageResponse(
- {/* Left side - Simplified abacus visualization (HTML/CSS) - Can't use StaticAbacus here because ImageResponse only supports - basic HTML elements, not custom React components */} + {/* Left side - Abacus from @soroban/abacus-react (server-side rendered) */}
- {/* Simple abacus representation with 3 columns */} -
- {/* Column 1 */} -
- {/* Reckoning bar */} -
- {/* Beads - simplified representation */} -
- {[...Array(2)].map((_, i) => ( -
- ))} -
-
- - {/* Column 2 */} -
-
-
- {[...Array(2)].map((_, i) => ( -
- ))} -
-
- - {/* Column 3 */} -
-
-
- {[...Array(2)].map((_, i) => ( -
- ))} -
-
-
-
+ dangerouslySetInnerHTML={{ + __html: `${svgContent}`, + }} + /> {/* Right side - Text content */}