e30e75b5d4
Code Quality / Oxlint + Oxfmt (push) Waiting to run
Code Quality / Template Sync (push) Waiting to run
Code Quality / Build Changed Packages (push) Waiting to run
Code Quality / Test Changed Packages (push) Waiting to run
Deploy Expo Example / Deploy Production (push) Waiting to run
Deploy Ink Example / Deploy Production (push) Waiting to run
Python Tests / pytest (assistant-stream, 3.10) (push) Waiting to run
Python Tests / pytest (assistant-stream, 3.12) (push) Waiting to run
Python Tests / pytest (assistant-ui-sync-server-api, 3.10) (push) Waiting to run
Python Tests / pytest (assistant-ui-sync-server-api, 3.12) (push) Waiting to run
Deploy Shadcn Registry / Deploy Production (push) Waiting to run
Template Metrics / LOC + Bundle Size (push) Waiting to run
Changesets / Create Version PR (push) Has been cancelled
31 lines
755 B
TypeScript
31 lines
755 B
TypeScript
import type { Metadata } from "next";
|
|
|
|
export const OG_IMAGE_SIZE = { width: 1200, height: 630 } as const;
|
|
|
|
export function createOgMetadata(
|
|
title: string,
|
|
description?: string | null,
|
|
): Pick<Metadata, "openGraph" | "twitter"> {
|
|
const params = new URLSearchParams();
|
|
params.set("title", title);
|
|
if (description) {
|
|
params.set("description", description);
|
|
}
|
|
const imageUrl = `/api/og?${params.toString()}`;
|
|
|
|
return {
|
|
openGraph: {
|
|
title,
|
|
description: description ?? undefined,
|
|
type: "article",
|
|
images: [{ url: imageUrl, ...OG_IMAGE_SIZE, alt: title }],
|
|
},
|
|
twitter: {
|
|
card: "summary_large_image",
|
|
title,
|
|
description: description ?? undefined,
|
|
images: [imageUrl],
|
|
},
|
|
};
|
|
}
|