Skip to content

Commit

Permalink
fix image
Browse files Browse the repository at this point in the history
  • Loading branch information
helios2003 committed Jul 1, 2024
1 parent d78d07f commit 9b03fa5
Show file tree
Hide file tree
Showing 3 changed files with 1,128 additions and 612 deletions.
21 changes: 11 additions & 10 deletions apps/studio-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,32 @@
"@asyncapi/protobuf-schema-parser": "^3.2.8",
"@asyncapi/react-component": "^1.2.2",
"@asyncapi/specs": "^6.5.4",
"@codemirror/view": "^6.26.3",
"@ebay/nice-modal-react": "^1.2.10",
"@headlessui/react": "^1.7.4",
"@hookstate/core": "^4.0.0-rc21",
"@monaco-editor/react": "^4.4.6",
"@tippyjs/react": "^4.2.6",
"js-base64": "^3.7.3",
"js-file-download": "^0.4.12",
"js-yaml": "^4.1.0",
"monaco-editor": "0.34.1",
"monaco-yaml": "4.0.2",
"react-hot-toast": "2.4.0",
"react-icons": "^4.6.0",
"reactflow": "^11.2.0",
"@stoplight/yaml": "^4.3.0",
"@codemirror/view": "^6.26.3",
"@tippyjs/react": "^4.2.6",
"@types/node": "20.4.6",
"@types/react": "18.2.18",
"@types/react-dom": "18.2.7",
"autoprefixer": "10.4.14",
"codemirror": "^6.0.1",
"eslint-config-next": "13.4.12",
"js-base64": "^3.7.3",
"js-file-download": "^0.4.12",
"js-yaml": "^4.1.0",
"monaco-editor": "0.34.1",
"monaco-yaml": "4.0.2",
"next": "14.2.3",
"node-fetch": "^3.3.2",
"postcss": "8.4.31",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hot-toast": "2.4.0",
"react-icons": "^4.6.0",
"reactflow": "^11.2.0",
"tailwindcss": "3.3.3",
"tippy.js": "^6.3.7",
"typescript": "5.1.6",
Expand Down
8 changes: 8 additions & 0 deletions apps/studio-next/src/app/api/crawler/route.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { NextRequest, NextResponse } from "next/server";
import parseURL from "@/helpers/parser";
import { DocumentInfo } from "@/types";
import fetch from "node-fetch";

export async function GET(request: NextRequest) {
try {
const searchParams = request.nextUrl.searchParams.get('base64');
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 crawlerInfo = `
<!DOCTYPE html>
<html lang="en">
Expand All @@ -17,6 +24,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}" />
</head>
</html>
`;
Expand Down
Loading

0 comments on commit 9b03fa5

Please sign in to comment.