feat(cms): Home/About/Services/Contact/Common Globals + JSON migration (MITHOME-87)
Payload Global configs mirroring proto/src/content/types.ts:
- src/globals/{Home,About,Services,Contact,Common}.ts
- src/globals/fields/stringArray.ts — shared helper: Payload has no
native string[] field, so every plain string array from the old
content types (trustBullets, paragraphs, features, spec items, …)
becomes an array of one-field { value } objects.
- home.partners is intentionally NOT included — that becomes its own
Partners collection (logo -> Media upload) in MITHOME-89, to avoid
two disagreeing sources for the same data.
- contact.form.fields.gdpr.label stays a plain textarea (not lexical
richText): the JSON source is a hand-written HTML string with an
<a> tag; richText's node-tree serialization would need its own
migration/render logic, out of scope for this bootstrap pass.
scripts/migrate-content-to-payload.ts: one-shot, idempotent Local API
migration reading the existing JSON files and calling updateGlobal —
does not touch or delete the JSON files. Run via the new
`npm run migrate:content` script.
Registered the five Globals in payload.config.ts.
Also included here (belongs with the previous "resolve double-root-
layout conflict" commit but didn't actually get staged there —
verified only now by diffing HEAD against the working tree):
(frontend)/layout.tsx's relative imports corrected to ../../ instead
of ../ (one directory deeper than the original src/app/layout.tsx).
Verified:
- npm run build / lint, tsc --noEmit, npm test (58 passed) all clean
- npm run migrate:content against the real dev MongoDB container,
then read back via payload.findGlobal() — hero.title, trustBullets,
services.items[0].features, footer.address, faq.items.length all
match the JSON source
- Real browser: logged into /admin, opened the Home global editor —
Hero/Trust bullets group renders and shows the migrated Hungarian
content correctly (see screenshot shared in chat)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
3183098926
commit
3132fcb8eb
@@ -0,0 +1,142 @@
|
||||
import type { GlobalConfig } from 'payload'
|
||||
|
||||
/**
|
||||
* Mirrors ContactPageContent (proto/src/content/types.ts) — MITHOME-87.
|
||||
*
|
||||
* WHY `gdpr.label` textarea és nem richText: a JSON forrás egy kézzel
|
||||
* beírt <a> taget tartalmazó HTML string (lásd contact.json). A lexical
|
||||
* richText mező más (JSON node-fa) szerializációt használna, ami extra
|
||||
* migrációs/render logikát igényelne — ezt itt, bootstrap szinten nem
|
||||
* bontjuk ki, marad egyszerű (HTML-t tartalmazó) szöveg mező.
|
||||
*/
|
||||
export const Contact: GlobalConfig = {
|
||||
slug: 'contact',
|
||||
admin: {
|
||||
group: 'Oldalak',
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'meta',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'title', type: 'text', required: true },
|
||||
{ name: 'description', type: 'textarea', required: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'hero',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'title', type: 'text', required: true },
|
||||
{ name: 'subtitle', type: 'text', required: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'form',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'title', type: 'text', required: true },
|
||||
{ name: 'successMessage', type: 'text', required: true },
|
||||
{ name: 'errorMessage', type: 'text', required: true },
|
||||
{
|
||||
name: 'fields',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'label', type: 'text', required: true },
|
||||
{ name: 'placeholder', type: 'text', required: true },
|
||||
{ name: 'error', type: 'text', required: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'email',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'label', type: 'text', required: true },
|
||||
{ name: 'placeholder', type: 'text', required: true },
|
||||
{ name: 'errorRequired', type: 'text', required: true },
|
||||
{ name: 'errorInvalid', type: 'text', required: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'subject',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'label', type: 'text', required: true },
|
||||
{ name: 'placeholder', type: 'text', required: true },
|
||||
{ name: 'error', type: 'text', required: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'message',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'label', type: 'text', required: true },
|
||||
{ name: 'placeholder', type: 'text', required: true },
|
||||
{ name: 'errorRequired', type: 'text', required: true },
|
||||
{ name: 'errorMinLength', type: 'text', required: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'gdpr',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'label', type: 'textarea', required: true },
|
||||
{ name: 'error', type: 'text', required: true },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{ name: 'submitButton', type: 'text', required: true },
|
||||
{ name: 'submittingButton', type: 'text', required: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'info',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'title', type: 'text', required: true },
|
||||
{
|
||||
name: 'email',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'title', type: 'text', required: true },
|
||||
{ name: 'responseTime', type: 'text', required: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'company',
|
||||
type: 'group',
|
||||
fields: [{ name: 'title', type: 'text', required: true }],
|
||||
},
|
||||
{
|
||||
name: 'webmail',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'title', type: 'text', required: true },
|
||||
{ name: 'linkText', type: 'text', required: true },
|
||||
{ name: 'subtitle', type: 'text', required: true },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'faq',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'title', type: 'text', required: true },
|
||||
{
|
||||
name: 'items',
|
||||
type: 'array',
|
||||
fields: [
|
||||
{ name: 'question', type: 'text', required: true },
|
||||
{ name: 'answer', type: 'textarea', required: true },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user