Files
ipal-kit/src/globals/SiteSettings/index.ts
T
Radosław Smoliński 24a98ff836 Merge SEO, GEO and Search Console track
Conflict in createContentHelpers.ts resolved by keeping both: isPathVisible (per-path, security track) and constructionPaths (per-list, SEO track).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	src/modules/frontend/createContentHelpers.ts
2026-10-22 17:48:22 +02:00

81 lines
2.8 KiB
TypeScript

import type { Field, GlobalConfig } from 'payload'
import { adminOrEditor } from '../../modules/access/index.js'
import { generalFields } from './fields/general.js'
import { themeFields } from './fields/theme.js'
type BuildSiteSettingsArgs = {
/** Extra fields injected by the client project */
additionalFields?: Field[]
/** "Under construction" tab (developer tool) — given when the pages module is on. */
constructionFields?: Field[]
/** "Emails" tab — given with `forms: { emailLayout: true }`. */
emailFields?: Field[]
/** "Search & AI" tab — search-engine verification, AI crawlers, llms.txt note (seo module). */
searchFields?: Field[]
/**
* Fields for the "System Pages" tab — page assignments by role (homepage,
* privacy policy, collection archives). Assembled by the caller, which is the
* only place that knows which modules are enabled. The tab is omitted when
* this is empty.
*/
systemPageFields?: Field[]
}
/**
* Builds the SiteSettings global.
*
* Composes tabs out of field groups; it deliberately doesn't know where those
* groups come from. Earlier it imported the pages and content modules directly,
* which meant a global — a presentation-layer concern — had an opinion about
* blogs. Now the plugin's composition root passes fields in, and adding a new
* kind of page assignment needs no change here.
*
* Uses unnamed tabs — data stays flat (siteSettings.siteName, not
* siteSettings.general.siteName). Client-provided fields land in their own
* "Custom" tab so core data paths never shift.
*/
export function buildSiteSettings({
additionalFields,
constructionFields,
emailFields,
searchFields,
systemPageFields,
}: BuildSiteSettingsArgs = {}): GlobalConfig {
return {
slug: 'site-settings',
access: {
read: () => true,
// Editors and admins only — a plain 'user' account (open sign-up) must
// not rewrite the brand, homepage or construction mode.
update: adminOrEditor,
},
admin: {
group: 'Settings',
},
fields: [
{
type: 'tabs',
tabs: [
{
fields: generalFields,
label: 'General',
},
{
fields: themeFields,
label: 'Theme',
},
...(systemPageFields?.length
? [{ fields: systemPageFields, label: 'System Pages' }]
: []),
...(searchFields?.length ? [{ fields: searchFields, label: 'Search & AI' }] : []),
...(emailFields?.length ? [{ fields: emailFields, label: 'Emails' }] : []),
...(constructionFields?.length ? [{ fields: constructionFields, label: 'Under construction' }] : []),
...(additionalFields?.length ? [{ fields: additionalFields, label: 'Custom' }] : []),
],
},
],
label: 'Site Settings',
}
}