This commit is contained in:
2026-07-31 23:21:51 +02:00
parent f6b4b36df8
commit f14f2cfd98
294 changed files with 5880 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
import { getLocalizedSlugs } from '../i18n/index.js';
/**
* Reads a document's slug in every locale — the map hreflang alternates are
* built from.
*
* Needs its own query because a document fetched in one locale returns `slug`
* as a plain string. Fetching with `locale: 'all'` turns *every* localized
* field into a locale→value map, which is right for the slug and wrong for
* everything else (a title map would break title composition), so this asks
* only for what it needs and at depth 0.
*/ export async function slugsAcrossLocales({ id, collection, config, payload }) {
const doc = await payload.findByID({
id,
collection: collection,
depth: 0,
locale: 'all'
});
return doc.slug && typeof doc.slug === 'object' ? getLocalizedSlugs({
config,
slugField: doc.slug
}) : {};
}
//# sourceMappingURL=slugsAcrossLocales.js.map