Files
websitedev/proto/src/globals/Home.ts
T
Do SikiandClaude Opus 5.5 829f543962 feat(cms): localize translatable Globals fields with lossless migration (MITHOME-111)
Mark every translatable text/textarea field of the Home, About, Services,
Contact and Common globals as localized. Icons, row ids, the external
flag and the postal address stay shared; CTA hrefs are localized because
internal routes differ per locale. String lists (paragraphs, bullets,
features, spec items) are localized at array level so locales can have
different item counts; structured rows share order/icons and localize
only their inner text.

Existing data is not re-seeded (that would overwrite admin edits): a
Payload migration wraps legacy values into { hu: value } on the published
global and every draft/version record, idempotently, and runs on
production startup via prodMigrations. Paths are derived from the Global
configs themselves so the migration cannot drift from the schema.

OpenSpec change: openspec/changes/localize-globals-mithome-111

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 00:52:26 +02:00

114 lines
4.0 KiB
TypeScript

import type { GlobalConfig } from 'payload'
import { stringArrayField } from './fields/stringArray'
import { globalVersions } from '../lib/payload-versions'
/**
* Mirrors HomePageContent (proto/src/content/types.ts) — MITHOME-87.
*
* WHY nincs `partners` mező: a home.partners.items a JSON-ban ma egy
* beágyazott lista, de a Payload oldalon önálló `Partners` collection lesz
* (logó = Media upload reference) — lásd MITHOME-89. Itt szándékosan
* kihagyjuk, nehogy két, egymásnak ellentmondó forrás legyen.
*
* MITHOME-111 lokalizáció: minden fordítható szöveg `localized: true`; az
* `icon`, a sor-`id` és az `external` közös. WHY a `cta.*.href` is
* lokalizált: a belső útvonal nyelvenként eltér (/hu/kapcsolat vs
* /en/contact, lásd PAGE_SLUGS). A string-listák (trustBullets, features)
* tömb-szinten lokalizáltak — nyelvenként eltérő elemszám lehet.
*/
export const Home: GlobalConfig = {
slug: 'home',
admin: {
group: 'Oldalak',
},
versions: globalVersions,
fields: [
{
name: 'hero',
type: 'group',
fields: [
{ name: 'title', type: 'text', required: true, localized: true },
{ name: 'subtitle', type: 'text', required: true, localized: true },
{ name: 'description', type: 'textarea', required: true, localized: true },
stringArrayField('trustBullets', 'Trust bullets', { localized: true }),
{
name: 'cta',
type: 'group',
fields: [
{
name: 'primary',
type: 'group',
fields: [
{ name: 'text', type: 'text', required: true, localized: true },
{ name: 'href', type: 'text', required: true, localized: true },
{ name: 'external', type: 'checkbox', defaultValue: false },
],
},
{
name: 'secondary',
type: 'group',
fields: [
{ name: 'text', type: 'text', required: true, localized: true },
{ name: 'href', type: 'text', required: true, localized: true },
{ name: 'external', type: 'checkbox', defaultValue: false },
],
},
],
},
],
},
{
name: 'about',
type: 'group',
fields: [
{ name: 'title', type: 'text', required: true, localized: true },
{
name: 'usps',
type: 'array',
fields: [
{ name: 'id', type: 'text', required: true },
{ name: 'title', type: 'text', required: true, localized: true },
{ name: 'description', type: 'textarea', required: true, localized: true },
{ name: 'icon', type: 'text', required: true },
],
},
],
},
{
name: 'services',
type: 'group',
fields: [
{ name: 'title', type: 'text', required: true, localized: true },
{ name: 'subtitle', type: 'text', required: true, localized: true },
{
name: 'items',
type: 'array',
fields: [
{ name: 'id', type: 'text', required: true },
{ name: 'title', type: 'text', required: true, localized: true },
{ name: 'description', type: 'textarea', required: true, localized: true },
{ name: 'icon', type: 'text', required: true },
stringArrayField('features', 'Features', { localized: true }),
{ name: 'ctaText', type: 'text', required: true, localized: true },
],
},
],
},
{
name: 'cta',
type: 'group',
fields: [
{ name: 'title', type: 'text', required: true, localized: true },
{ name: 'subtitle', type: 'textarea', required: true, localized: true },
{ name: 'button', type: 'text', required: true, localized: true },
],
},
{
name: 'serviceFeatures',
type: 'group',
fields: [{ name: 'title', type: 'text', required: true, localized: true }],
},
],
}