feat: share collection URL

This commit is contained in:
gosangam
2026-06-14 01:29:08 +05:30
parent b04ed1d3aa
commit 3accc753d0
5 changed files with 414 additions and 85 deletions
+36
View File
@@ -470,3 +470,39 @@ export function ogForPost(p: {
},
};
}
/** OG metadata for a public collection (`/c/<id>`). */
export function ogForCollection(c: {
id: string;
title: string;
description?: string | null;
itemCount?: number;
}) {
const imageUrl = new URL(
`/api/og/collection/${encodeURIComponent(c.id)}`,
SITE_URL,
).toString();
const title = c.title;
const count =
typeof c.itemCount === "number"
? `${c.itemCount} post${c.itemCount === 1 ? "" : "s"}`
: "A collection";
const description =
c.description?.trim() || `${count} on Prabhupāda Says`;
return {
title,
description,
openGraph: {
title,
description,
images: [{ url: imageUrl, width: 1200, height: 630, alt: title }],
siteName: "Prabhupāda Says",
},
twitter: {
card: "summary_large_image" as const,
title,
description,
images: [imageUrl],
},
};
}