Files
ipal-kit/dist/modules/content/archiveFields.js
T
2026-08-03 12:24:28 +02:00

27 lines
1.1 KiB
JavaScript

import { archiveFieldName } from './types.js';
/**
* Builds one relationship field per content collection, pointing at the
* client's Pages collection.
*
* Sits alongside the system-page roles (homepage, privacy policy) because it's
* the same idea: a page referenced by function rather than by slug. The
* assignment is locale-agnostic — one page document — while the resulting path
* is locale-aware, since the page's slug is localized. Assign the "Artykuły"
* page once and you get /pl/artykuly and /en/articles from its own slugs.
*/ export function buildArchiveFields(content, pagesSlug) {
return content.collections.map((collection)=>{
const label = collection.label ?? collection.slug;
return {
name: archiveFieldName(collection.slug),
type: 'relationship',
admin: {
description: `Page listing ${label}. Its slug becomes the URL segment for entries (e.g. /pl/artykuly/moj-wpis).`
},
label: `${label} — archive page`,
maxDepth: 1,
relationTo: pagesSlug
};
});
}
//# sourceMappingURL=archiveFields.js.map