feat: share collection URL
This commit is contained in:
@@ -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],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user