Files
ocenka-web/src/shared/lib/metaInfo/metaInfo.ts
2025-12-11 15:12:20 +03:00

71 lines
1.5 KiB
TypeScript

import { Metadata } from 'next';
type TMetaInfo = {
title: string;
description: string;
companyName: string;
phone: string;
host: string;
path: string;
ogImageTitle: string;
ogImageDescription: string;
width?: number;
height?: number;
locale?: string;
creator?: string;
};
function metaInfo({ ...props }: TMetaInfo): Metadata {
const {
title,
description,
companyName,
phone,
host,
path = '',
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: `${host}${path}`,
images: [
{
url: `${host}/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: `${host}/api/og/?title=${ogImageTitle}&description=${ogImageDescription}`,
width: width,
height: height,
alt: `${title} - ${companyName}`,
},
],
},
};
}
export { metaInfo };