Skip to content

Commit

Permalink
avoid parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
helios2003 committed Jul 2, 2024
1 parent cc07e19 commit 6ec2186
Showing 1 changed file with 1 addition and 67 deletions.
68 changes: 1 addition & 67 deletions apps/studio-next/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,74 +1,8 @@
import dynamic from 'next/dynamic';
import parseURL from '@/helpers/parser';
import { DocumentInfo } from '@/types';
const StudioWrapper = dynamic(() => import('@/components/StudioWrapper'), {ssr: false})
import { Metadata } from 'next';
import ogImage from '@/img/meta-studio-og-image.jpeg';

type Props = {
searchParams: { [key: string]: string | undefined };
};

export async function generateMetadata({
searchParams,
}: Props): Promise<Metadata> {
const base64Doc = searchParams["base64"];
let metadata: Metadata = {
metadataBase: new URL("https://studio-studio-next.vercel.app"),
openGraph: {
type: "website",
title: "AsyncAPI Studio",
description:
"Studio for AsyncAPI specification, where you can validate, view preview documentation, and generate templates from AsyncAPI document.",
url: "https://studio-studio-next.vercel.app",
images: [
{
url: ogImage.src,
alt: "AsyncAPI default image",
},
],
},
twitter: {
site: "@AsyncAPISpec",
},
};
if (base64Doc) {
try {
const ogInfo: DocumentInfo = await parseURL(base64Doc);
metadata = {
...metadata,
openGraph: {
...metadata.openGraph,
title: ogInfo.title,
description: ogInfo.description,
images: [
{
url: `https://ogp-studio.vercel.app/api/og?title=${ogInfo.title}&description=${ogInfo.description}&numServers=${ogInfo.numServers}&numChannels=${ogInfo.numChannels}`,
alt: "AsyncAPI default image",
},
],
},
twitter: {
...metadata.twitter,
title: ogInfo.title,
description: ogInfo.description,
images: [
{
url: `https://ogp-studio.vercel.app/api/og?title=${ogInfo.title}&description=${ogInfo.description}&numServers=${ogInfo.numServers}&numChannels=${ogInfo.numChannels}`,
alt: "AsyncAPI default image",
},
],
},
};
} catch (error) {
console.error("Error parsing URL:", error);
}
}

return metadata;
}
export default async function Home({ searchParams }: Props) {
await generateMetadata({ searchParams });
export default async function Home() {
return (
<StudioWrapper />
)
Expand Down

0 comments on commit 6ec2186

Please sign in to comment.