2023-08-16 23:55:57 +08:00
|
|
|
import { Metadata } from 'next';
|
|
|
|
import siteMetadata from '@/data/siteMetadata';
|
2023-08-16 23:29:22 +08:00
|
|
|
|
|
|
|
interface PageSEOProps {
|
2023-08-16 23:55:57 +08:00
|
|
|
title: string;
|
|
|
|
description?: string;
|
|
|
|
image?: string;
|
2023-08-16 23:29:22 +08:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2023-08-16 23:55:57 +08:00
|
|
|
[key: string]: any;
|
2023-08-16 23:29:22 +08:00
|
|
|
}
|
|
|
|
|
2023-08-16 23:55:57 +08:00
|
|
|
export function genPageMetadata({
|
|
|
|
title,
|
|
|
|
description,
|
|
|
|
image,
|
|
|
|
...rest
|
|
|
|
}: PageSEOProps): Metadata {
|
2023-08-16 23:29:22 +08:00
|
|
|
return {
|
|
|
|
title,
|
|
|
|
openGraph: {
|
|
|
|
title: `${title} | ${siteMetadata.title}`,
|
|
|
|
description: description || siteMetadata.description,
|
|
|
|
url: './',
|
|
|
|
siteName: siteMetadata.title,
|
|
|
|
images: image ? [image] : [siteMetadata.socialBanner],
|
|
|
|
locale: 'en_US',
|
|
|
|
type: 'website',
|
|
|
|
},
|
|
|
|
twitter: {
|
|
|
|
title: `${title} | ${siteMetadata.title}`,
|
|
|
|
card: 'summary_large_image',
|
|
|
|
images: image ? [image] : [siteMetadata.socialBanner],
|
|
|
|
},
|
|
|
|
...rest,
|
2023-08-16 23:55:57 +08:00
|
|
|
};
|
2023-08-16 23:29:22 +08:00
|
|
|
}
|