fix: update opengraph gen
This commit is contained in:
69
src/shared/lib/metaInfo/metaInfo.ts
Normal file
69
src/shared/lib/metaInfo/metaInfo.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import { Metadata } from 'next';
|
||||
|
||||
type TMetaInfo = {
|
||||
title: string;
|
||||
description: string;
|
||||
companyName: string;
|
||||
phone: string;
|
||||
url: string;
|
||||
ogImageTitle: string;
|
||||
ogImageDescription: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
locale?: string;
|
||||
creator?: string;
|
||||
};
|
||||
|
||||
function metaInfo({ ...props }: TMetaInfo): Metadata {
|
||||
const {
|
||||
title,
|
||||
description,
|
||||
companyName,
|
||||
phone,
|
||||
url,
|
||||
ogImageTitle,
|
||||
ogImageDescription,
|
||||
width = 600,
|
||||
height = 315,
|
||||
locale = 'ru_RU',
|
||||
creator = '@ditraso',
|
||||
} = props;
|
||||
|
||||
return {
|
||||
title: `${title} | ${companyName}`,
|
||||
description: `${description} ${phone}`,
|
||||
openGraph: {
|
||||
title: title,
|
||||
description: description,
|
||||
url: url,
|
||||
images: [
|
||||
{
|
||||
url: `${url}/api/og/?title=${ogImageTitle}&description=${ogImageDescription}`,
|
||||
secureUrl: `${url}/api/og/?title=${ogImageTitle}&description=${ogImageDescription}`,
|
||||
width: width,
|
||||
height: height,
|
||||
alt: `${title} - ${companyName}`,
|
||||
},
|
||||
],
|
||||
locale: locale,
|
||||
type: 'website',
|
||||
siteName: `${title} - ${companyName}`,
|
||||
},
|
||||
twitter: {
|
||||
card: 'summary_large_image',
|
||||
title: `${title} - ${companyName}`,
|
||||
description: `${description} ${phone}`,
|
||||
creator: creator,
|
||||
images: [
|
||||
{
|
||||
url: `${url}/api/og/?title=${ogImageTitle}&description=${ogImageDescription}`,
|
||||
width: width,
|
||||
height: height,
|
||||
alt: `${title} - ${companyName}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export { metaInfo };
|
||||
Reference in New Issue
Block a user