init commit for iPAL-kit plugin
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import type { Field } from 'payload'
|
||||
|
||||
import { CONSENT_CATEGORIES } from '../../modules/consent/index.js'
|
||||
|
||||
/**
|
||||
* Fields for the CookieSettings global — GDPR consent banner copy, editable
|
||||
* per locale. The privacy-policy link is NOT stored here: it comes from the
|
||||
* pages module (system page role 'privacyPolicy'), keeping one source of truth.
|
||||
*/
|
||||
export const cookieSettingsFields: Field[] = [
|
||||
{
|
||||
name: 'message',
|
||||
type: 'textarea',
|
||||
admin: {
|
||||
description: 'Main consent message shown in the banner.',
|
||||
},
|
||||
localized: true,
|
||||
},
|
||||
{
|
||||
name: 'settingsTitle',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'Heading for the detailed settings panel.',
|
||||
},
|
||||
localized: true,
|
||||
},
|
||||
{
|
||||
name: 'buttons',
|
||||
type: 'group',
|
||||
admin: {
|
||||
description: 'Button labels.',
|
||||
},
|
||||
fields: [
|
||||
{ name: 'acceptAll', type: 'text', localized: true },
|
||||
{ name: 'reject', type: 'text', localized: true },
|
||||
{ name: 'settings', type: 'text', localized: true },
|
||||
{ name: 'save', type: 'text', localized: true },
|
||||
{ name: 'back', type: 'text', localized: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'categories',
|
||||
type: 'array',
|
||||
admin: {
|
||||
description: 'Per-category titles and descriptions.',
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'key',
|
||||
type: 'select',
|
||||
options: CONSENT_CATEGORIES.map((c) => ({ label: c, value: c })),
|
||||
required: true,
|
||||
},
|
||||
{ name: 'title', type: 'text', localized: true },
|
||||
{ name: 'description', type: 'textarea', localized: true },
|
||||
],
|
||||
},
|
||||
]
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { GlobalConfig } from 'payload'
|
||||
|
||||
import { cookieSettingsFields } from './fields.js'
|
||||
|
||||
/**
|
||||
* Builds the CookieSettings global — consent banner copy managed by editors.
|
||||
* Public read (the banner needs it on the frontend for anonymous visitors).
|
||||
*/
|
||||
export function buildCookieSettings(): GlobalConfig {
|
||||
return {
|
||||
slug: 'cookie-settings',
|
||||
access: {
|
||||
read: () => true,
|
||||
},
|
||||
admin: {
|
||||
group: 'Settings',
|
||||
},
|
||||
fields: cookieSettingsFields,
|
||||
label: 'Cookie Settings',
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user