add opengraph image + embed

This commit is contained in:
horsefacts 2024-11-27 10:41:18 -05:00 committed by lucas-neynar
parent 0e2e706c48
commit f957312437
No known key found for this signature in database
3 changed files with 68 additions and 10 deletions

13
src/app/app.tsx Normal file
View File

@ -0,0 +1,13 @@
"use client";
import dynamic from "next/dynamic";
const Demo = dynamic(() => import("~/components/Demo"), {
ssr: false,
});
export default function App() {
return (
<Demo />
);
}

View File

@ -0,0 +1,22 @@
import { ImageResponse } from "next/og";
export const alt = "Farcaster Frames V2 Demo";
export const size = {
width: 800,
height: 800,
};
export const contentType = "image/png";
export default async function Image() {
return new ImageResponse(
(
<div tw="h-full w-full flex flex-col justify-center items-center relative">
<h1 tw="text-6xl">Frames v2 Demo</h1>
</div>
),
{
...size,
}
);
}

View File

@ -1,15 +1,38 @@
"use client"; import { Metadata } from "next";
import App from "./app";
import dynamic from "next/dynamic"; const appUrl = process.env.NEXT_PUBLIC_URL;
const Demo = dynamic(() => import("~/components/Demo"), { const frame = {
ssr: false, version: "next",
}); imageUrl: `${appUrl}/opengraph-image`,
button: {
title: "Launch Frame",
action: {
type: "launch_frame",
name: "Farcaster Frames v2 Demo",
url: appUrl,
splashImageUrl: `${appUrl}/splash.png`,
splashBackgroundColor: "#f7f7f7",
},
},
};
export const revalidate = 300;
export async function generateMetadata(): Promise<Metadata> {
return {
title: "Farcaster Frames v2 Demo",
openGraph: {
title: "Farcaster Frames v2 Demo",
description: "A Farcaster Frames v2 demo app.",
},
other: {
"fc:frame": JSON.stringify(frame),
},
};
}
export default function Home() { export default function Home() {
return ( return (<App />);
<main className="min-h-screen flex flex-col p-4">
<Demo />
</main>
);
} }