cleanup metadata generation
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 54s
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 54s
This commit is contained in:
@ -1,23 +0,0 @@
|
||||
import { Metadata } from "next";
|
||||
|
||||
type Fallback = {
|
||||
title: string;
|
||||
description: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates metadata for a fallback embed.
|
||||
*
|
||||
* @param title the title of the embed
|
||||
* @param description the description of the embed
|
||||
* @returns the metadata for the embed
|
||||
*/
|
||||
export function embedFallback({ title, description }: Fallback): Metadata {
|
||||
return {
|
||||
title: `${title}`,
|
||||
openGraph: {
|
||||
title: `${title}`,
|
||||
description: description,
|
||||
},
|
||||
};
|
||||
}
|
37
src/common/embed.ts
Normal file
37
src/common/embed.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { Metadata } from "next";
|
||||
|
||||
type Embed = {
|
||||
title: string;
|
||||
description: string;
|
||||
image?: string | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates metadata for a embed.
|
||||
*
|
||||
* @param title the title of the embed
|
||||
* @param description the description of the embed
|
||||
* @returns the metadata for the embed
|
||||
*/
|
||||
export function generateEmbed({ title, description, image }: Embed): Metadata {
|
||||
const metadata: Metadata = {
|
||||
title: `${title}`,
|
||||
openGraph: {
|
||||
title: `${title}`,
|
||||
description: description,
|
||||
},
|
||||
twitter: {
|
||||
card: "summary",
|
||||
},
|
||||
};
|
||||
|
||||
if (image) {
|
||||
metadata.openGraph!.images = [
|
||||
{
|
||||
url: image || "",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
Reference in New Issue
Block a user