import { Metadata } from "next";
import { headers } from "next/headers";

export async function getDefaultMetadata(): Promise<Metadata> {
  const headersList = await headers();
  const mainUrl = headersList.get("x-main-url") ?? "";
  const fullUrl = headersList.get("x-full-url") ?? "";
  const siteName = headersList.get("x-site-name") ?? "";
  const metaDesc = headersList.get("x-meta-desc") ?? "";

  return {
    metadataBase: new URL(mainUrl),
    title: siteName,
    description: metaDesc,
    robots: {
      index: true,
      follow: true,
      "max-image-preview": "large",
      "max-snippet": -1,
      "max-video-preview": -1,
    },
    openGraph: {
      siteName,
      description: metaDesc,
      type: "website",
      locale: "en_US",
      url: fullUrl,
    },
    twitter: {
      card: "summary_large_image",
    },
    alternates: {
      canonical: "./",
    },
  };
}
