import type { Metadata } from "next";

export function generateSEO({
  title,
  description,
  url,
  image = "/og-image.png",
  keywords = [],
  twitterHandle = "@vibrantprint",
  siteName = "Vibrant Printing & Graphics",
//   type = "website",
}: {
  title: string;
  description: string;
  url: string;
  image?: string;
  keywords?: string[];
  twitterHandle?: string;
  siteName?: string;
  type?: Metadata["openGraph"] extends { type: infer T } ? T : string;
}): Metadata {

  return {
    metadataBase: new URL("https://vibrant-print.vercel.app"),
    // https://vibrant-print.vercel.app/

    // Title & Description
    title: `${title} | ${siteName}`,
    description,

    // SEO Keywords
    keywords: [
      ...keywords,
    ],

    // Canonical URL
    alternates: {
      canonical: url,
    },

    // Robots (SEO permissions)
    robots: {
      index: true,
      follow: true,
    //   googleBot: {
    //     index: true,
    //     follow: true,
    //     "max-image-preview": "large",
    //     "max-video-preview": -1,
    //     "max-snippet": -1,
    //   },
    },

    // OpenGraph Meta Tags (Facebook, LinkedIn, WhatsApp)
    openGraph: {
      title: `${title} | ${siteName}`,
      description,
      url,
    //   type,
      siteName,
      images: [
        {
          url: image,       
          width: 1200,
          height: 630,
          alt: title,
        },
      ],
    },

    // Twitter/X Meta Tags
    twitter: {
      card: "summary_large_image",
      site: twitterHandle,
      creator: twitterHandle,
      title: `${title} | ${siteName}`,
      description,
      images: [image],
    },
  };
}
