forked from l2beat/l2beat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add metadata to DA pages (l2beat#5679)
- Loading branch information
Showing
8 changed files
with
128 additions
and
2 deletions.
There are no files selected for viewing
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
BIN
+536 KB
packages/frontend/src/app/(side-nav)/data-availability/risk/opengraph-image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+528 KB
packages/frontend/src/app/(side-nav)/data-availability/summary/opengraph-image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...rontend/src/app/(top-nav)/data-availability/projects/[layer]/[bridge]/opengraph-image.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { daLayers } from '@l2beat/config' | ||
import { ImageResponse } from 'next/og' | ||
import { NextResponse } from 'next/server' | ||
import { ProjectOpengraphImage } from '~/components/opengraph-image/project' | ||
import { env } from '~/env' | ||
|
||
export const runtime = 'nodejs' | ||
|
||
const size = { | ||
width: 1200, | ||
height: 630, | ||
} | ||
|
||
export async function generateStaticParams() { | ||
return daLayers.map((project) => ({ | ||
layer: project.display.slug, | ||
})) | ||
} | ||
|
||
export async function generateImageMetadata({ params }: Props) { | ||
return [ | ||
{ | ||
id: params.layer, | ||
size, | ||
alt: `Project page for ${params.layer}`, | ||
contentType: 'image/png', | ||
}, | ||
] | ||
} | ||
|
||
interface Props { | ||
params: { | ||
layer: string | ||
} | ||
} | ||
|
||
export default async function Image({ params }: Props) { | ||
const project = daLayers.find((p) => p.display.slug === params.layer) | ||
if (!project) { | ||
return NextResponse.json({ error: 'Project not found' }, { status: 404 }) | ||
} | ||
const baseUrl = env.VERCEL_URL | ||
? `https://${env.VERCEL_URL}` | ||
: 'http://localhost:3000' | ||
const [robotoMedium, robotoBold] = [ | ||
fetch(`${baseUrl}/fonts/roboto/roboto-latin-500.ttf`).then((res) => | ||
res.arrayBuffer(), | ||
), | ||
fetch(`${baseUrl}/fonts/roboto/roboto-latin-700.ttf`).then((res) => | ||
res.arrayBuffer(), | ||
), | ||
] | ||
return new ImageResponse( | ||
<ProjectOpengraphImage | ||
background="da-beat" | ||
baseUrl={baseUrl} | ||
slug={project.display.slug} | ||
name={project.display.name} | ||
size={size} | ||
/>, | ||
{ | ||
...size, | ||
fonts: [ | ||
{ | ||
name: 'roboto', | ||
data: await robotoMedium, | ||
style: 'normal', | ||
weight: 500, | ||
}, | ||
{ | ||
name: 'roboto', | ||
data: await robotoBold, | ||
style: 'normal', | ||
weight: 700, | ||
}, | ||
], | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters