import { buildLocalizedPath, getLocaleCodes } from '../i18n/index.js'; /** * Builds a map of locale → URL for hreflang alternate links, suitable for * Next.js Metadata `alternates.languages`. * * Bridges SEO and i18n: for each configured locale that the document has a * slug in, it produces the locale-aware path (via buildLocalizedPath), * optionally prefixed with an absolute origin. * * @example * buildHreflangAlternates({ * slugs: { pl: 'o-nas', en: 'about' }, * config, * baseUrl: 'https://example.com', * }) * // → { pl: 'https://example.com/pl/o-nas', en: 'https://example.com/en/about' } */ export function buildHreflangAlternates({ baseUrl, config, homeSlug = 'home', prefix, slugs }) { const origin = baseUrl?.replace(/\/$/, '') ?? ''; const alternates = {}; for (const locale of getLocaleCodes(config)){ const path = buildLocalizedPath({ config, homeSlug, locale, prefix, slugs }); if (path) { alternates[locale] = `${origin}${path}`; } } return alternates; } //# sourceMappingURL=hreflang.js.map //# sourceMappingURL=hreflang.js.map