1
0
mirror of https://github.com/vercel/commerce.git synced 2025-07-22 12:24:18 +00:00
Files
.vscode
app
components
cart
grid
icons
layout
product
carousel.tsx
label.tsx
loading-dots.tsx
logo-square.tsx
opengraph-image.tsx
price.tsx
prose.tsx
welcome-toast.tsx
fonts
framework
lib
.env.example
.env.production
.gitignore
.graphqlrc.yml
README.md
license.md
next.config.ts
package.json
pnpm-lock.yaml
postcss.config.mjs
redeploy.txt
tsconfig.json
commerce/components/opengraph-image.tsx
Lee Robinson 7f8f9ff1a3 use cache
2025-02-09 11:38:22 -06:00

46 lines
1.1 KiB
TypeScript

import { ImageResponse } from 'next/og';
import LogoIcon from './icons/logo';
import { join } from 'path';
import { readFile } from 'fs/promises';
export type Props = {
title?: string;
};
export default async function OpengraphImage(
props?: Props
): Promise<ImageResponse> {
const { title } = {
...{
title: process.env.SITE_NAME
},
...props
};
const file = await readFile(join(process.cwd(), './fonts/Inter-Bold.ttf'));
const font = Uint8Array.from(file).buffer;
return new ImageResponse(
(
<div tw="flex h-full w-full flex-col items-center justify-center bg-black">
<div tw="flex flex-none items-center justify-center border border-neutral-700 h-[160px] w-[160px] rounded-3xl">
<LogoIcon width="64" height="58" fill="white" />
</div>
<p tw="mt-12 text-6xl font-bold text-white">{title}</p>
</div>
),
{
width: 1200,
height: 630,
fonts: [
{
name: 'Inter',
data: font,
style: 'normal',
weight: 700
}
]
}
);
}