import type { Metadata } from "next";

interface MetadataProps {
  title: string;
  description: string;
  ogImage?: string;
  canonicalUrl?: string;
  type?: "website" | "article";
  noIndex?: boolean;
}

export function generateMetadata({
  title,
  description,
  ogImage,
  canonicalUrl,
  type = "website",
  noIndex = false,
}: MetadataProps): Metadata {
  const fullTitle = title.includes("Nitescape") ? title : `${title} - Nitescape`;

  return {
    title: fullTitle,
    description,
    openGraph: {
      title: fullTitle,
      description,
      images: ogImage ? [{ url: ogImage }] : [],
      type,
    },
    twitter: {
      card: "summary_large_image",
      title: fullTitle,
      description,
      images: ogImage ? [ogImage] : [],
    },
    alternates: canonicalUrl
      ? {
          canonical: `https://nitescape.com${canonicalUrl}`,
        }
      : undefined,
    robots: {
      index: !noIndex,
      follow: !noIndex,
    },
  };
}
