fix(cms): resolve internal CTA links per locale via a page selector (MITHOME-123)
The home hero CTA stored a free-text href "/kapcsolat" that predated the locale-prefixed routing (MITHOME-114), so the main call-to-action led to a 404. Internal targets were typed by hand and could never follow the locale or its translated slug. CTA links now choose between an internal page (home/about/services/ contact/privacy/terms) and an external URL. Page links are resolved per request with localePath(), giving /hu/kapcsolat and /en/contact; external links (webmail) keep their localized href. A Payload migration converts existing internal paths to page links on the published global and every draft/version, idempotently and independent of the locale migration's order. The global-doc iteration shared with MITHOME-111 moved to src/lib/migrate-global-docs.ts; the JSON seed emits the new shape too. Verified on a copy of the staging DB: both migrations ran on startup, /hu and /en CTAs point to their contact pages (200), webmail unchanged, admin shows the selector, toggles the fields and blocks publishing a URL link without a URL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
38d34fab4c
commit
e8ff7adeb5
@@ -1,6 +1,7 @@
|
||||
import type { GlobalConfig } from 'payload'
|
||||
|
||||
import { stringArrayField } from './fields/stringArray'
|
||||
import { ctaLinkGroup } from './fields/ctaLink'
|
||||
import { globalVersions } from '../lib/payload-versions'
|
||||
|
||||
/**
|
||||
@@ -13,9 +14,11 @@ import { globalVersions } from '../lib/payload-versions'
|
||||
*
|
||||
* 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.
|
||||
* lokalizált: egy külső cél nyelvenként eltérhet. Belső oldalra a CTA
|
||||
* oldalválasztóval mutat (MITHOME-123, fields/ctaLink.ts) — a nyelvhelyes
|
||||
* útvonalat a frontend számolja (/hu/kapcsolat vs /en/contact). A
|
||||
* string-listák (trustBullets, features) tömb-szinten lokalizáltak —
|
||||
* nyelvenként eltérő elemszám lehet.
|
||||
*/
|
||||
export const Home: GlobalConfig = {
|
||||
slug: 'home',
|
||||
@@ -36,24 +39,8 @@ export const Home: GlobalConfig = {
|
||||
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 },
|
||||
],
|
||||
},
|
||||
ctaLinkGroup('primary'),
|
||||
ctaLinkGroup('secondary'),
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user