import type { Metadata } from 'next'
import { type Locale, localHref } from './site'

/** Title, description, link previews and the other-language address of one page. */
export function pageMeta(locale: Locale, path: string, title?: string | null, description?: string | null): Metadata {
  return {
    title: title || 'Thinkera',
    description: description || undefined,
    alternates: {
      canonical: localHref(locale, path),
      languages: { ar: localHref('ar', path), en: localHref('en', path) },
    },
    openGraph: { title: title || undefined, description: description || undefined, type: 'website', locale: locale === 'ar' ? 'ar_EG' : 'en_US' },
  }
}
