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: dynamically set meta tags #1453

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
15ebdb7
initial commit
spsjvc Jan 19, 2024
b44af22
oops
spsjvc Jan 19, 2024
214c596
add script for generating
spsjvc Jan 19, 2024
1d7467e
fix
spsjvc Jan 19, 2024
0e156f4
generate batch
spsjvc Jan 19, 2024
58ed46e
try
spsjvc Jan 19, 2024
b855091
fix
spsjvc Jan 19, 2024
b782e50
clean up
spsjvc Jan 20, 2024
4606d6b
add .gitkeep
spsjvc Jan 20, 2024
2e51019
Merge branch 'master' into feat-dynamic-meta
chrstph-dvx Mar 8, 2024
c07de3f
Merge remote-tracking branch 'origin/master' into feat-dynamic-meta
fionnachan Aug 21, 2024
5082805
wip
fionnachan Aug 21, 2024
e6c36d2
update
fionnachan Aug 21, 2024
fda6208
Merge remote-tracking branch 'origin/master' into feat-dynamic-meta
fionnachan Aug 30, 2024
0303730
make site load WIP
fionnachan Aug 30, 2024
ec6dd4e
Merge remote-tracking branch 'origin/master' into feat-dynamic-meta
fionnachan Sep 2, 2024
8e21070
updaet
fionnachan Sep 2, 2024
dfbd9e1
add back type
fionnachan Sep 2, 2024
d365f31
Merge remote-tracking branch 'origin/master' into feat-dynamic-meta
fionnachan Sep 12, 2024
768a515
Merge branch 'master' into feat-dynamic-meta
fionnachan Sep 23, 2024
6dc3dfd
Merge branch 'feat-dynamic-meta' of github.com:OffchainLabs/arbitrum-…
fionnachan Nov 1, 2024
93cee14
Merge remote-tracking branch 'origin/master' into feat-dynamic-meta
fionnachan Nov 1, 2024
5dbfa09
update
fionnachan Nov 1, 2024
00a8ad4
fix: tx panel rendering (#1918)
fionnachan Nov 4, 2024
e66876d
Merge branch 'master' into feat-dynamic-meta
fionnachan Nov 4, 2024
80639b2
look like figma
fionnachan Nov 4, 2024
1c9c7ba
update
fionnachan Nov 5, 2024
a8cd1b5
Merge remote-tracking branch 'origin/master' into feat-dynamic-meta
fionnachan Nov 6, 2024
5f385b0
make svg work
fionnachan Nov 6, 2024
eb7ba07
Merge remote-tracking branch 'origin/master' into feat-dynamic-meta
fionnachan Nov 6, 2024
b28bf2a
update
fionnachan Nov 6, 2024
0be460c
Merge remote-tracking branch 'origin/master' into feat-dynamic-meta
fionnachan Nov 7, 2024
9b8ecf4
wip
fionnachan Nov 7, 2024
4329ac6
update
fionnachan Nov 7, 2024
ef36cc9
Merge remote-tracking branch 'origin/master' into feat-dynamic-meta
fionnachan Nov 8, 2024
6ff2f59
update polter logo
fionnachan Nov 8, 2024
d98c7c0
Merge remote-tracking branch 'origin/master' into feat-dynamic-meta
fionnachan Nov 8, 2024
e053fe8
update
fionnachan Nov 8, 2024
477c8b9
lean up
fionnachan Nov 8, 2024
b4e91d8
clean up
fionnachan Nov 8, 2024
c6e8569
move site title
fionnachan Nov 8, 2024
533d985
prettier
fionnachan Nov 8, 2024
0ea0d8a
Merge branch 'master' into feat-dynamic-meta
fionnachan Nov 8, 2024
837a659
address comments
fionnachan Nov 11, 2024
31f17f1
Merge branch 'feat-dynamic-meta' of github.com:OffchainLabs/arbitrum-…
fionnachan Nov 11, 2024
caaa8d5
Merge branch 'master' into feat-dynamic-meta
fionnachan Nov 14, 2024
bfaf657
Merge branch 'master' into feat-dynamic-meta
fionnachan Nov 14, 2024
bfebedc
Merge remote-tracking branch 'origin/master' into feat-dynamic-meta
fionnachan Nov 18, 2024
34aa681
Merge branch 'master' into feat-dynamic-meta
fionnachan Nov 18, 2024
40045e9
add sepolia and arb sepolia
fionnachan Nov 19, 2024
8456fee
Merge branch 'master' into feat-dynamic-meta
fionnachan Nov 19, 2024
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
3 changes: 3 additions & 0 deletions packages/arb-token-bridge-ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ yarn-error.log*
# Next.js
.next
next-env.d.ts

# auto-generated images
public/images/__auto-generated
7 changes: 5 additions & 2 deletions packages/arb-token-bridge-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"react-toastify": "^9.1.1",
"react-use": "^17.2.4",
"react-virtualized": "^9.22.3",
"sharp": "^0.32.6",
"sharp": "^0.33.5",
"swr": "^2.1.2",
"tailwind-merge": "^2.0.0",
"use-query-params": "^2.2.1",
Expand All @@ -49,8 +49,9 @@
"zustand": "^4.3.9"
},
"scripts": {
"predev": "yarn generateDenylist && yarn generateOpenGraphImages",
"dev": "next dev",
"prebuild": "yarn generateDenylist",
"prebuild": "yarn generateDenylist && yarn generateOpenGraphImages",
dewanshparashar marked this conversation as resolved.
Show resolved Hide resolved
"postinstall": "patch-package",
"build": "next build",
"start": "next start",
Expand All @@ -60,6 +61,7 @@
"lint:fix": "tsc && eslint 'src/**/*.{js,ts,tsx}' --quiet --fix",
"prettier:format": "prettier --config-precedence file-override --write \"src/**/*.{tsx,ts,scss,md,json}\"",
"generateDenylist": "ts-node --project ./scripts/tsconfig.json ./scripts/generateDenylist.ts",
"generateOpenGraphImages": "ts-node --project ./scripts/tsconfig.json ./src/generateOpenGraphImages.tsx",
"generateCoreChainsToMonitor": "ts-node --project ./scripts/tsconfig.json ./scripts/generateCoreChainsToMonitor.ts",
"generateOrbitChainsToMonitor": "ts-node --project ./scripts/tsconfig.json ./scripts/generateOrbitChainsToMonitor.ts"
},
Expand Down Expand Up @@ -110,6 +112,7 @@
"postinstall-postinstall": "^2.1.0",
"prettier": "^2.7.1",
"prettier-plugin-tailwindcss": "^0.1.11",
"satori": "^0.10.11",
"start-server-and-test": "^2.0.0",
"tailwindcss": "^3.2.4",
"ts-node": "^10.9.1",
Expand Down
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion packages/arb-token-bridge-ui/scripts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"compilerOptions": {
// typescript options here
"moduleResolution": "NodeNext"
"moduleResolution": "NodeNext",
"jsx": "react"
}
}
Binary file not shown.
Binary file not shown.
344 changes: 344 additions & 0 deletions packages/arb-token-bridge-ui/src/generateOpenGraphImages.tsx

Large diffs are not rendered by default.

84 changes: 82 additions & 2 deletions packages/arb-token-bridge-ui/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ import 'tippy.js/themes/light.css'
import '@rainbow-me/rainbowkit/styles.css'

import { Layout } from '../components/common/Layout'
import { siteTitle } from './_document'

import '../styles/tailwind.css'
import '../styles/purple.css'
import {
ChainKeyQueryParam,
getChainForChainKeyQueryParam
} from '../types/ChainQueryParam'
import { isUserRejectedError } from '../util/isUserRejectedError'
import { isNetwork } from '../util/networks'

const siteTitle = 'Bridge to Arbitrum'

dayjs.extend(utc)
dayjs.extend(relativeTime)
Expand Down Expand Up @@ -74,10 +80,84 @@ if (
})
}

export default function App({ Component, pageProps }: AppProps) {
function DynamicMetaData({
sourceChainSlug,
destinationChainSlug
}: {
sourceChainSlug: ChainKeyQueryParam
destinationChainSlug: ChainKeyQueryParam
}) {
const sourceChainInfo = getChainForChainKeyQueryParam(sourceChainSlug)
const destinationChainInfo =
getChainForChainKeyQueryParam(destinationChainSlug)
const { isOrbitChain: isSourceOrbitChain } = isNetwork(sourceChainInfo.id)
const { isOrbitChain: isDestinationOrbitChain } = isNetwork(
destinationChainInfo.id
)

const siteDescription = `Bridge from ${sourceChainInfo.name} to ${destinationChainInfo.name} using the Arbitrum Bridge. Built to scale Ethereum, Arbitrum brings you 10x lower costs while inheriting Ethereum’s security model. Arbitrum is a Layer 2 Optimistic Rollup.`
const siteDomain = 'https://bridge.arbitrum.io'

let metaImagePath = `${sourceChainInfo.id}-to-${destinationChainInfo.id}.jpg`

if (isSourceOrbitChain) {
metaImagePath = `${sourceChainInfo.id}.jpg`
}

if (isDestinationOrbitChain) {
metaImagePath = `${destinationChainInfo.id}.jpg`
}

return (
<>
<meta name="description" content={siteDescription} />

{/* <!-- Facebook Meta Tags --> */}
<meta name="og:url" property="og:url" content={siteDomain} />
<meta name="og:type" property="og:type" content="website" />
<meta name="og:title" property="og:title" content={siteTitle} />
<meta
name="og:description"
property="og:description"
content={siteDescription}
/>
<meta
name="og:image"
property="og:image"
content={`${siteDomain}/images/__auto-generated/open-graph/${metaImagePath}`}
/>

{/* <!-- Twitter Meta Tags --> */}
<meta name="twitter:card" content="summary_large_image" />
<meta
name="twitter:domain"
property="twitter:domain"
content="bridge.arbitrum.io"
/>
<meta name="twitter:url" property="twitter:url" content={siteDomain} />
<meta name="twitter:title" content={siteTitle} />
<meta name="twitter:description" content={siteDescription} />
<meta
name="twitter:image"
content={`${siteDomain}/images/__auto-generated/open-graph/${metaImagePath}`}
/>
</>
)
}

export default function App({ Component, pageProps, router }: AppProps) {
const sourceChainSlug = (router.query.sourceChain?.toString() ??
'ethereum') as ChainKeyQueryParam
const destinationChainSlug = (router.query.destinationChain?.toString() ??
'arbitrum-one') as ChainKeyQueryParam

return (
<>
<Head>
<DynamicMetaData
sourceChainSlug={sourceChainSlug}
destinationChainSlug={destinationChainSlug}
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{siteTitle}</title>
</Head>
Expand Down
20 changes: 0 additions & 20 deletions packages/arb-token-bridge-ui/src/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { Html, Head, Main, NextScript } from 'next/document'

export const siteTitle = 'Bridge to Arbitrum'
const siteDomain = 'https://bridge.arbitrum.io'
const siteDescription =
'Built to scale Ethereum, Arbitrum brings you 10x lower costs while inheriting Ethereum’s security model. Arbitrum is a Layer 2 Optimistic Rollup.'

export default function Document() {
return (
<Html lang="en">
Expand All @@ -13,21 +8,6 @@ export default function Document() {
<link rel="icon" href="/logo.png" />

<meta name="theme-color" content="#000000" />
<meta name="description" content={siteDescription} />
{/* <!-- Facebook Meta Tags --> */}
<meta property="og:url" content={siteDomain} />
<meta property="og:type" content="website" />
<meta property="og:title" content={siteTitle} />
<meta property="og:description" content={siteDescription} />
<meta property="og:image" content={`${siteDomain}/og-image.jpg`} />

{/* <!-- Twitter Meta Tags --> */}
<meta name="twitter:card" content="summary_large_image" />
<meta property="twitter:domain" content="bridge.arbitrum.io" />
<meta property="twitter:url" content={siteDomain} />
<meta name="twitter:title" content={siteTitle} />
<meta name="twitter:description" content={siteDescription} />
<meta name="twitter:image" content={`${siteDomain}/og-image.jpg`} />
</Head>
<body>
<Main />
Expand Down
1 change: 0 additions & 1 deletion packages/arb-token-bridge-ui/src/types/ChainQueryParam.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Chain } from 'wagmi'
import * as chains from 'wagmi/chains'

import {
ChainId,
getCustomChainFromLocalStorageById,
Expand Down
2 changes: 2 additions & 0 deletions packages/arb-token-bridge-ui/src/util/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export function saveCustomChainToLocalStorage(newCustomChain: ChainWithRpcUrl) {
}

const newCustomChains = [...getCustomChainsFromLocalStorage(), newCustomChain]

localStorage.setItem(
customChainLocalStorageKey,
JSON.stringify(newCustomChains)
Expand All @@ -203,6 +204,7 @@ export function removeCustomChainFromLocalStorage(chainId: number) {
const newCustomChains = getCustomChainsFromLocalStorage().filter(
chain => chain.chainId !== chainId
)

localStorage.setItem(
customChainLocalStorageKey,
JSON.stringify(newCustomChains)
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-token-bridge-ui/src/util/orbitChainsData.json
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@
"color": "#03AB2A",
"network": {
"name": "Polter Testnet",
"logo": "/images/PolterTestnetLogo.png",
"logo": "/images/PolterTestnetLogo.webp",
"description": "A gaming testnet for Aavegotchi's Geist Mainnet."
},
"nativeTokenData": {
Expand Down
3 changes: 1 addition & 2 deletions packages/arb-token-bridge-ui/src/util/wagmi/getWagmiChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import {
baseSepolia,
base
} from './wagmiAdditionalNetworks'
import { ChainId } from '../networks'
import { getCustomChainFromLocalStorageById } from '../networks'
import { ChainId, getCustomChainFromLocalStorageById } from '../networks'
import { orbitChains } from '../orbitChainsList'

export function getWagmiChain(chainId: number): Chain {
Expand Down
13 changes: 11 additions & 2 deletions packages/arb-token-bridge-ui/src/util/wagmi/setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createClient, configureChains } from 'wagmi'
import { mainnet, arbitrum } from '@wagmi/core/chains'
import { publicProvider } from 'wagmi/providers/public'
import { jsonRpcProvider } from 'wagmi/providers/jsonRpc'
import { connectorsForWallets, getDefaultWallets } from '@rainbow-me/rainbowkit'
import { trustWallet, okxWallet } from '@rainbow-me/rainbowkit/wallets'

Expand All @@ -16,7 +17,7 @@ import {
baseSepolia
} from './wagmiAdditionalNetworks'
import { isTestingEnvironment } from '../CommonUtils'
import { getCustomChainsFromLocalStorage, ChainId } from '../networks'
import { getCustomChainsFromLocalStorage, ChainId, rpcURLs } from '../networks'
import { getOrbitChains } from '../orbitChainsList'
import { getWagmiChain } from './getWagmiChain'
import { customInfuraProvider } from '../infura'
Expand Down Expand Up @@ -131,7 +132,15 @@ export function getProps(targetChainKey: string | null) {
//
// https://github.com/wagmi-dev/references/blob/main/packages/connectors/src/walletConnect.ts#L114
getChains(sanitizeTargetChainKey(targetChainKey)),
[customInfuraProvider(), publicProvider()]
[
customInfuraProvider(),
publicProvider(),
jsonRpcProvider({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this diff required in this PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is because otherwise the transfer panel will not render

#1918 (comment)

rpc: chain => ({
http: rpcURLs[chain.id]!
})
})
]
)

const { wallets } = getDefaultWallets({
Expand Down
11 changes: 9 additions & 2 deletions packages/arb-token-bridge-ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"additional.d.ts",
"next.config.js",
"next-env.d.ts",
".next/types/**/*.ts"
".next/types/**/*.ts",
"build/types/**/*.ts"
],
"compilerOptions": {
"noEmit": true,
Expand All @@ -15,7 +16,13 @@
"@/images/*": ["./public/images/*"],
"@/icons/*": ["./public/icons/*"],
"@/token-bridge-sdk/*": ["./src/token-bridge-sdk/*"]
}
},
"plugins": [
{
"name": "next"
}
],
"strictNullChecks": true
dewanshparashar marked this conversation as resolved.
Show resolved Hide resolved
},
"exclude": ["node_modules"]
}
Loading
Loading