Skip to content

Commit

Permalink
Twitter post opmtimization
Browse files Browse the repository at this point in the history
  • Loading branch information
FranklinBarto committed Feb 12, 2024
1 parent daa583c commit 824ccc0
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/app/opengraph-image.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { ImageResponse } from 'next/og'

// Route segment config
export const runtime = 'edge'

// Image metadata
export const alt = 'Moon Landing page'
export const size = {
width: 1200,
height: 630,
}

export const contentType = 'image/png'

// Image generation
export default async function Image() {
// Font
const interSemiBold = fetch(
new URL('./Inter-SemiBold.ttf', import.meta.url)
).then((res) => res.arrayBuffer())

return new ImageResponse(
(
// ImageResponse JSX element
<div
style={{
fontSize: 128,
backgroundImage: `url('https://raw.githubusercontent.com/Frankothe196/moon-mission-landing-page/main/app-screenshot.png')`,
backgroundPosition: 'center',
backgroundSize:'cover',
width: '100%',
height: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
Moon Landing Page Concept
</div>
),
// ImageResponse options
{
// For convenience, we can re-use the exported opengraph-image
// size config to also set the ImageResponse's width and height.
...size,
fonts: [
{
name: 'Inter',
data: await interSemiBold,
style: 'normal',
weight: 400,
},
],
}
)
}

0 comments on commit 824ccc0

Please sign in to comment.