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>
100 lines
4.2 KiB
TypeScript
100 lines
4.2 KiB
TypeScript
/**
|
|
* Payload CMS configuration (MITHOME-86 — alapinstalláció).
|
|
*
|
|
* WHY a saját MongoDB kapcsolatot használjuk: a projekt már MongoDB-t futtat
|
|
* (proto/src/lib/mongodb.ts) — Payload a `mongooseAdapter`-en keresztül
|
|
* ugyanabba az adatbázisba ír, nincs szükség külön DB-re/szerverre.
|
|
*
|
|
* MITHOME-87: Home/About/Services/Contact/Common Globals hozzáadva — ezek
|
|
* tükrözik a proto/src/content/pages/*.json + common.json struktúráját.
|
|
* MITHOME-88: LegalPages collection hozzáadva (adatvedelem, hasznalati-
|
|
* feltetelek).
|
|
* MITHOME-89: Partners + Media collection (MVP — feltöltés, a vágás/
|
|
* áttetszővé tétel szerkesztő külön, MITHOME-118).
|
|
* MITHOME-110: lokalizáció bekapcsolva (hu alapértelmezett, en). A mezőnkénti
|
|
* `localized: true` retrofit a Globals/LegalPages configokon külön ticket
|
|
* (MITHOME-111/112) — ez a ticket csak magát a mechanizmust kapcsolja be.
|
|
* MITHOME-120: admin gyorskeresés (QuickSearch) az admin.components.header
|
|
* slotba regisztrálva — teljes szöveges keresés minden Global/Collection
|
|
* mezőjében, mindkét locale-ban.
|
|
* MITHOME-94: ContactSubmissions collection — a /api/contact korábban egy
|
|
* nyers, Payload-on kívüli Mongo collection-be (`contact_submissions`,
|
|
* proto/src/lib/mongodb.ts) írt, amit az ügyfél nem látott sehol az admin
|
|
* felületen. Mostantól Payload collection, a route.ts a Local API-n ír bele.
|
|
* MITHOME-111: a Globals fordítható mezői lokalizáltak; a meglévő adatot a
|
|
* src/migrations/20260929_localize_globals.ts alakítja át (prodMigrations).
|
|
*/
|
|
import path from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
import { buildConfig } from 'payload'
|
|
import { mongooseAdapter } from '@payloadcms/db-mongodb'
|
|
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
|
import sharp from 'sharp'
|
|
|
|
import { Users } from './collections/Users'
|
|
import { LegalPages } from './collections/LegalPages'
|
|
import { Media } from './collections/Media'
|
|
import { Partners } from './collections/Partners'
|
|
import { ContactSubmissions } from './collections/ContactSubmissions'
|
|
import { Home } from './globals/Home'
|
|
import { About } from './globals/About'
|
|
import { Services } from './globals/Services'
|
|
import { Contact } from './globals/Contact'
|
|
import { Common } from './globals/Common'
|
|
import { migrations } from './migrations'
|
|
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
|
|
export default buildConfig({
|
|
// Admin felület — bejelentkezés az Users collection-nel. Access control /
|
|
// jelszó-politika: MITHOME-90 (src/collections/Users.ts).
|
|
admin: {
|
|
user: Users.slug,
|
|
components: {
|
|
// MITHOME-120: gyorskeresés minden admin oldal tetején.
|
|
// WHY 'src/...' és nem './components/...': a Payload komponens-útvonal
|
|
// az admin.importMap.baseDir-hez relatív, ami alapértelmezésben
|
|
// process.cwd() (a `generate:importmap` a proto/ mappából fut, NEM a
|
|
// payload.config.ts mappájából).
|
|
header: ['./src/components/admin/QuickSearch#QuickSearch'],
|
|
},
|
|
},
|
|
|
|
editor: lexicalEditor(),
|
|
|
|
collections: [Users, LegalPages, Media, Partners, ContactSubmissions],
|
|
|
|
globals: [Home, About, Services, Contact, Common],
|
|
|
|
// MITHOME-109/110: hu alapértelmezett (URL-prefix nélkül), en /en/ alatt
|
|
// (Next.js routing oldala: MITHOME-114). fallback:true -> amíg egy mezőnek
|
|
// nincs angol fordítása, a magyar érték jelenik meg — nem üres oldal.
|
|
localization: {
|
|
locales: ['hu', 'en'],
|
|
defaultLocale: 'hu',
|
|
fallback: true,
|
|
},
|
|
|
|
secret: process.env.PAYLOAD_SECRET || '',
|
|
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
|
|
db: mongooseAdapter({
|
|
url: process.env.MONGODB_URI || '',
|
|
// MITHOME-111: pending migrations run automatically on production
|
|
// startup (NODE_ENV=production — staging + prod containers), so a deploy
|
|
// never serves the localized schema on un-migrated data.
|
|
prodMigrations: migrations,
|
|
}),
|
|
|
|
// WHY: Payload sends anonymous usage telemetry to its own servers by
|
|
// default — GDPR-tudatosan kikapcsolva, mivel a projekt self-hosted és
|
|
// az ügyfél adatai nem hagyhatják el a saját infrastruktúránkat.
|
|
telemetry: false,
|
|
|
|
sharp,
|
|
})
|