import type { Metadata } from 'next';

/**
 * Canonical origin for absolute URLs in social previews. UEF confirmed on
 * 28 August 2026 that unitedeconomicforum.com is the address going live, so
 * that is now the default rather than the Vercel preview host. NEXT_PUBLIC_SITE_URL
 * still overrides it, which is what keeps preview deployments pointing at
 * themselves instead of at production.
 */
export const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL ?? 'https://unitedeconomicforum.com';

const OG_IMAGE = {
  url: '/og.png',
  width: 1200,
  height: 630,
  alt: 'United Economic Forum — Enriching Communities, Empowering Entrepreneurs',
};

/**
 * Link-preview tags for WhatsApp, LinkedIn, Facebook and X. Next.js replaces a
 * parent's `openGraph`/`twitter` wholesale when a page defines its own, so each
 * page spreads this to keep the image and site name rather than inheriting.
 */
export function social(title: string, description: string, path = '/'): Pick<Metadata, 'openGraph' | 'twitter'> {
  return {
    openGraph: {
      type: 'website',
      siteName: 'United Economic Forum',
      locale: 'en_IN',
      url: path,
      title,
      description,
      images: [OG_IMAGE],
    },
    twitter: {
      card: 'summary_large_image',
      title,
      description,
      images: [OG_IMAGE],
    },
  };
}
