import { Metadata } from 'next';

type TMetaInfo = {
  title: string;
  description: string;
  companyName: string;
  phone: string;
  host: string;
  path: string;
  ogImageUrl: string;
  width?: number;
  height?: number;
  locale?: string;
  creator?: string;
};

function metaInfo({ ...props }: TMetaInfo): Metadata {
  const {
    title,
    description,
    companyName,
    phone,
    host,
    path = '',
    ogImageUrl,
    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}/${ogImageUrl}`,
          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}/${ogImageUrl}`,
          width: width,
          height: height,
          alt: `${title} - ${companyName}`,
        },
      ],
    },
  };
}

export { metaInfo };
