diff --git a/src/app/app.tsx b/src/app/app.tsx index 09927df..f5757df 100644 --- a/src/app/app.tsx +++ b/src/app/app.tsx @@ -6,8 +6,8 @@ const Demo = dynamic(() => import("~/components/Demo"), { ssr: false, }); -export default function App() { - return ( - - ); +export default function App( + { title }: { title?: string } = { title: "Frames v2 Demo" } +) { + return ; } diff --git a/src/app/frames/hello/[name]/opengraph-image.tsx b/src/app/frames/hello/[name]/opengraph-image.tsx new file mode 100644 index 0000000..6f76183 --- /dev/null +++ b/src/app/frames/hello/[name]/opengraph-image.tsx @@ -0,0 +1,32 @@ +import { ImageResponse } from "next/og"; + +export const runtime = "edge"; + +export const alt = "Hello Frame"; +export const size = { + width: 600, + height: 400, +}; + +export const contentType = "image/png"; + +interface Props { + params: Promise<{ + name: string; + }>; +} + +export default async function Image({ params }: Props) { + const { name } = await params; + + return new ImageResponse( + ( +
+

Hello, {name}

+
+ ), + { + ...size, + } + ); +} diff --git a/src/app/frames/hello/[name]/page.tsx b/src/app/frames/hello/[name]/page.tsx new file mode 100644 index 0000000..b47b45c --- /dev/null +++ b/src/app/frames/hello/[name]/page.tsx @@ -0,0 +1,47 @@ +import { Metadata } from "next"; +import App from "~/app/app"; + +const appUrl = process.env.NEXT_PUBLIC_URL; + +interface Props { + params: Promise<{ + name: string; + }>; +} + +export async function generateMetadata({ params }: Props): Promise { + const { name } = await params; + + const frame = { + version: "next", + imageUrl: `${appUrl}/opengraph-image`, + button: { + title: "Launch Frame", + action: { + type: "launch_frame", + name: "Farcaster Frames v2 Demo", + url: `${appUrl}/hello/${name}/`, + splashImageUrl: `${appUrl}/splash.png`, + splashBackgroundColor: "#f7f7f7", + }, + }, + }; + + return { + title: `Hello, ${name}`, + description: `A personalized hello frame for ${name}`, + openGraph: { + title: `Hello, ${name}`, + description: `A personalized hello frame for ${name}`, + }, + other: { + "fc:frame": JSON.stringify(frame), + }, + }; +} + +export default async function HelloNameFrame({ params }: Props) { + const { name } = await params; + + return ; +} diff --git a/src/app/frames/hello/opengraph-image.tsx b/src/app/frames/hello/opengraph-image.tsx new file mode 100644 index 0000000..a2ddd7b --- /dev/null +++ b/src/app/frames/hello/opengraph-image.tsx @@ -0,0 +1,24 @@ +import { ImageResponse } from "next/og"; + +export const runtime = "edge"; + +export const alt = "Hello Frame"; +export const size = { + width: 600, + height: 400, +}; + +export const contentType = "image/png"; + +export default async function Image() { + return new ImageResponse( + ( +
+

Hello, world!

+
+ ), + { + ...size, + } + ); +} diff --git a/src/app/frames/hello/page.tsx b/src/app/frames/hello/page.tsx new file mode 100644 index 0000000..c5ec0a8 --- /dev/null +++ b/src/app/frames/hello/page.tsx @@ -0,0 +1,35 @@ +import { Metadata } from "next"; +import App from "~/app/app"; + +const appUrl = process.env.NEXT_PUBLIC_URL; + +const frame = { + version: "next", + imageUrl: `${appUrl}/hello/opengraph-image`, + button: { + title: "Launch Frame", + action: { + type: "launch_frame", + name: "Farcaster Frames v2 Demo", + url: `${appUrl}/hello/`, + splashImageUrl: `${appUrl}/splash.png`, + splashBackgroundColor: "#f7f7f7", + }, + }, +}; + +export const metadata: Metadata = { + title: "Hello, world!", + description: "A simple hello world frame", + openGraph: { + title: "Hello, world!", + description: "A simple hello world frame", + }, + other: { + "fc:frame": JSON.stringify(frame), + }, +}; + +export default function HelloFrame() { + return ; +} diff --git a/src/app/opengraph-image.tsx b/src/app/opengraph-image.tsx index c73206a..43202c1 100644 --- a/src/app/opengraph-image.tsx +++ b/src/app/opengraph-image.tsx @@ -2,8 +2,8 @@ import { ImageResponse } from "next/og"; export const alt = "Farcaster Frames V2 Demo"; export const size = { - width: 800, - height: 800, + width: 600, + height: 400, }; export const contentType = "image/png"; diff --git a/src/components/Demo.tsx b/src/components/Demo.tsx index dc54e5c..a44f190 100644 --- a/src/components/Demo.tsx +++ b/src/components/Demo.tsx @@ -14,7 +14,9 @@ import { config } from "~/components/providers/WagmiProvider"; import { Button } from "~/components/ui/Button"; import { truncateAddress } from "~/lib/truncateAddress"; -export default function Demo() { +export default function Demo( + { title }: { title?: string } = { title: "Frames v2 Demo" } +) { const [isSDKLoaded, setIsSDKLoaded] = useState(false); const [context, setContext] = useState(); const [isContextOpen, setIsContextOpen] = useState(false); @@ -123,7 +125,7 @@ export default function Demo() { return (
-

Frames v2 Demo

+

{title}

Context