export function buildPublicSeoLinks(seo) {
  const links = []

  if (seo?.canonical) {
    links.push({
      rel: 'canonical',
      href: seo.canonical,
    })
  }

  for (const entry of Array.isArray(seo?.hreflang) ? seo.hreflang : []) {
    if (!entry?.locale || !entry?.href) {
      continue
    }

    links.push({
      rel: 'alternate',
      hreflang: entry.locale,
      href: entry.href,
    })
  }

  if (seo?.xDefault) {
    links.push({
      rel: 'alternate',
      hreflang: 'x-default',
      href: seo.xDefault,
    })
  }

  return links
}
