Skip to content

Commit

Permalink
add image url instead of string
Browse files Browse the repository at this point in the history
  • Loading branch information
helios2003 committed Jul 1, 2024
1 parent 9b03fa5 commit cc07e19
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions apps/studio-next/src/app/api/crawler/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ export async function GET(request: NextRequest) {
if (!searchParams) return new NextResponse(null, { status: 200 });
const info: DocumentInfo = await parseURL(searchParams);

const ogImageurl = `https://ogp-studio.vercel.app/api/og?title=${info.title}&description=${info.description}&numServers=${info.numServers}&numChannels=${info.numChannels}`;
const ogImage = await fetch(ogImageurl);
const ogImageBuffer = await ogImage.arrayBuffer();
const ogImageBase64 = Buffer.from(ogImageBuffer).toString('base64');
const ogImageurl = `https://ogp-studio.vercel.app/api/og?title=${encodeURIComponent(info.title!)}&description=${encodeURIComponent(info.description!)}&numServers=${info.numServers}&numChannels=${info.numChannels}`;

const crawlerInfo = `
<!DOCTYPE html>
Expand All @@ -24,7 +21,7 @@ export async function GET(request: NextRequest) {
<title>${info.title}</title>
${info.title ? `<meta property="og:title" content="${info.title}" />` : ''}
${info.description ? `<meta property="og:description" content="${info.description}" />` : ''}
<meta property="og:image" content="data:image/png;base64,${ogImageBase64}" />
<meta property="og:image" content=${ogImageurl} />
</head>
</html>
`;
Expand Down

0 comments on commit cc07e19

Please sign in to comment.