Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding Farcaster Frames and OG Image #29

Merged
merged 9 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions packages/nextjs/components/MetaHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL ? `https://${process.env.NEXT
export const MetaHeader = ({
title = "Scaffold-ETH 2 - Open source toolkit to build dApps on Ethereum",
description = "An open-source, up-to-date toolkit for building decentralized applications (dapps) on the Ethereum blockchain. It's designed to make it easier for developers to create and deploy smart contracts and build user interfaces that interact with those contracts.",
image = "thumbnail.jpg",
image = "og-image.png",
carletex marked this conversation as resolved.
Show resolved Hide resolved
twitterCard = "summary_large_image",
children,
}: MetaHeaderProps) => {
const imageUrl = baseUrl + image;
const twitterImageUrl = baseUrl + "twitterThumbnail.jpg";
const twitterImageUrl = baseUrl + "twitterThumbnail.png";

return (
<Head>
Expand All @@ -43,6 +43,20 @@ export const MetaHeader = ({
<>
<meta property="og:image" content={imageUrl} />
<meta name="twitter:image" content={twitterImageUrl} />

<meta property="fc:frame" content="vNext" />
<meta property="fc:frame:image" content={imageUrl} />

<meta property="fc:frame:button:1" content="🛠️ GitHub" />
<meta property="fc:frame:button:1:action" content="link" />
<meta property="fc:frame:button:1:target" content="https://github.com/scaffold-eth/scaffold-eth-2" />

<meta property="fc:frame:button:2" content="📃 Docs" />
<meta property="fc:frame:button:2:action" content="link" />
<meta property="fc:frame:button:2:target" content="https://docs.scaffoldeth.io/" />

<meta property="fc:frame:button:3" content="Features →" />
<meta property="fc:frame:post_url" content={`${baseUrl}api?id=1`} />
</>
)}
{twitterCard && <meta name="twitter:card" content={twitterCard} />}
Expand Down
49 changes: 49 additions & 0 deletions packages/nextjs/pages/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import type { NextApiRequest, NextApiResponse } from "next";

const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
: "http://localhost:3000";

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const { query } = req;

let idAsNumber = 1;

if (query && query.id) {
idAsNumber = Number(query.id);
}

const nextId = idAsNumber + 1;

if (idAsNumber === 6) {
res.status(200).send(`<!DOCTYPE html><html><head>
<title>Scaffold-ETH 2 - Open source toolkit to build dApps on Ethereum</title>
<meta property="og:image" content="${baseUrl}/frames/buidlguidl.jpg" />
<meta property="fc:frame" content="vNext" />
<meta property="fc:frame:image" content="${baseUrl}/frames/buidlguidl.jpg" />
<meta property="fc:frame:button:1" content="🛠️ GitHub" />
<meta property="fc:frame:button:1:action" content="link" />
<meta property="fc:frame:button:1:target" content="https://github.com/scaffold-eth/scaffold-eth-2" />
<meta property="fc:frame:button:2" content="📃 Docs" />
<meta property="fc:frame:button:2:action" content="link" />
<meta property="fc:frame:button:2:target" content="https://docs.scaffoldeth.io/" />
<meta property="fc:frame:button:3" content="💬 Telegram" />
<meta property="fc:frame:button:3:action" content="link" />
<meta property="fc:frame:button:3:target" content="https://t.me/joinchat/KByvmRe5wkR-8F_zz6AjpA" />
</head></html>`);
} else {
res.status(200).send(`<!DOCTYPE html><html><head>
<title>Scaffold-ETH 2 - Open source toolkit to build dApps on Ethereum</title>
<meta property="og:image" content="${baseUrl}/frames/frame-${idAsNumber}.png" />
<meta property="fc:frame" content="vNext" />
<meta property="fc:frame:image" content="${baseUrl}/frames/frame-${idAsNumber}.png" />
<meta property="fc:frame:button:1" content="Next →" />
<meta property="fc:frame:post_url" content="${baseUrl}/api?id=${nextId}" />
</head></html>`);
}
} catch (err) {
console.log("err", err);
res.status(500).send({ error: "failed to load frame" });
}
}
Binary file added packages/nextjs/public/frames/buidlguidl.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/nextjs/public/frames/frame-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/nextjs/public/frames/frame-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/nextjs/public/frames/frame-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/nextjs/public/frames/frame-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/nextjs/public/frames/frame-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/nextjs/public/og-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/nextjs/public/twitterThumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 23 additions & 5 deletions packages/nextjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"compilerOptions": {
"target": "es2020",
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -15,9 +19,23 @@
"jsx": "preserve",
"incremental": true,
"paths": {
"~~/*": ["./*"]
}
"~~/*": [
"./*"
]
},
"plugins": [
{
"name": "next"
}
]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
Loading