import type { Metadata } from "next";

const descriptions: Record<string, string> = {
  "/about":
    "Learn about MaxCredit, our loan services and our Clementi office in Singapore. Find contact information and details about applying online.",
  "/personal-loan":
    "Explore MaxCredit personal loans in Singapore. Read about eligibility, application documents and repayment before contacting our Clementi office.",
  "/business-loan":
    "Explore MaxCredit business loans in Singapore. Read the application and repayment FAQs, then contact our team to discuss your business financing needs.",
  "/foreigner-loan":
    "Explore MaxCredit foreigner loans in Singapore. Find answers about eligibility, required documents, applications and repayment in our loan FAQs.",
  "/payday-loan":
    "Explore MaxCredit payday loans in Singapore. Read answers about applications, eligibility and repayment, and contact our team with questions.",
  "/debt-consolidation-plan":
    "Explore MaxCredit debt consolidation plans in Singapore. Read how consolidation works, check application details and discuss repayment with our team.",
  "/home-renovation-loan":
    "Explore MaxCredit home renovation loans in Singapore. Read about application documents, renovation financing and repayment in our loan FAQs.",
};

export function pageMetadata(
  title: string,
  path: string,
  description: string,
  noindex = false,
): Metadata {
  description = descriptions[path] ?? description;
  const url = new URL(path, "https://maxcredit.sg").href;
  return {
    title,
    description,
    alternates: { canonical: url },
    robots: noindex
      ? { index: false, follow: true }
      : {
          index: true,
          follow: true,
          "max-image-preview": "large",
          "max-snippet": -1,
        },
    openGraph: {
      type: "website",
      locale: "en_SG",
      siteName: "MaxCredit",
      title,
      description,
      url,
      images: [
        {
          url: "https://maxcredit.sg/opengraph-image",
          width: 1200,
          height: 630,
          alt: "MaxCredit",
        },
      ],
    },
    twitter: {
      card: "summary_large_image",
      title,
      description,
      images: [
        { url: "https://maxcredit.sg/opengraph-image", alt: "MaxCredit" },
      ],
    },
  };
}
