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

36 lines
1.3 KiB
JavaScript

import { ALL_SYSTEM_PAGE_ROLES } from './types.js';
/** Admin-facing labels per role. */ const ROLE_LABELS = {
cookiePolicy: 'Cookie Policy',
homepage: 'Homepage',
privacyPolicy: 'Privacy Policy'
};
/** Admin descriptions per role. */ const ROLE_DESCRIPTIONS = {
cookiePolicy: 'Page linked from the cookie consent banner.',
homepage: 'Page served at the locale root (e.g. /pl, /en).',
privacyPolicy: 'Page linked as the privacy policy.'
};
/**
* Builds one relationship field per configured system-page role.
*
* Each field points at the client's Pages collection (via the provided slug)
* and holds a single document reference. The referenced document's slug is
* localized, so the same assignment resolves to /pl/strona-glowna and
* /en/home at runtime — role assignment is locale-agnostic, path resolution
* is locale-aware (see getSystemPagePath).
*/ export function buildSystemPagesFields(pages) {
const roles = pages.roles?.length ? pages.roles : [
...ALL_SYSTEM_PAGE_ROLES
];
return roles.map((role)=>({
name: role,
type: 'relationship',
admin: {
description: ROLE_DESCRIPTIONS[role]
},
label: ROLE_LABELS[role],
maxDepth: 1,
relationTo: pages.slug
}));
}
//# sourceMappingURL=systemPagesFields.js.map