feat(frontend): Payload Local API + hu/en locale routing (MITHOME-91/114)
CI Pipeline with Test Management / 🧪 Run Tests & Generate Reports (push) Waiting to run
CI Pipeline with Test Management / 🐳 Docker Integration Tests (push) Blocked by required conditions
CI Pipeline with Test Management / 🏗️ Build Docker Image (push) Blocked by required conditions
CI Pipeline with Test Management / 📊 Generate Test Summary (push) Blocked by required conditions
Test Reporting & Gherkin Analysis / 🧪 Run Tests & Generate Reports (push) Waiting to run
Test Reporting & Gherkin Analysis / 📊 Analyze Test Coverage (push) Blocked by required conditions
Test Reporting & Gherkin Analysis / 🔄 Sync with Linear (push) Blocked by required conditions
Test Reporting & Gherkin Analysis / ⚡ Performance Monitoring (push) Blocked by required conditions

Replaces the JSON content system with Payload's Local API across every
frontend page, and introduces symmetric locale-prefixed routing
(/hu/..., /en/...) with per-locale translated slugs — supersedes the
earlier "hu unprefixed" decision (see chat 2026-09-10).

Routing structure:
- src/app/(frontend)/layout.tsx: now a minimal shell (html/body, theme
  script, ThemeProvider) — no longer locale-aware.
- src/app/(frontend)/page.tsx: redirects bare "/" to the default
  locale (/hu).
- src/app/(frontend)/not-found.tsx: explicit 404 for the (frontend)
  group — without it, Next's built-in fallback collided with the
  (payload) group's own root and reproduced the "double html / script
  tag" symptom from MITHOME-87, but only on notFound() paths. Verified
  fixed in both dev and a real production (standalone) server; the
  remaining "script tag" console warning on invalid routes turned out
  to be Turbopack dev-mode-only noise (zero console errors in
  production) — confirmed by building and running .next/standalone
  directly.
- src/app/(frontend)/[locale]/layout.tsx: validates the locale segment
  (generateStaticParams hu/en, notFound() otherwise), fetches Common +
  Home via Payload, renders Header/Footer/staging-banner.
- src/app/(frontend)/[locale]/page.tsx: home, fetches Home global +
  Partners collection.
- src/app/(frontend)/[locale]/[slug]/page.tsx: catch-all for about/
  services/contact/privacy/terms — resolves slug -> PageKey via
  src/lib/i18n.ts's PAGE_SLUGS map (generateStaticParams pre-renders
  all 10 locale×slug combinations), generateMetadata per page.

New lib layer:
- src/lib/i18n.ts: Locale/PageKey types, PAGE_SLUGS (translated slugs
  per locale), localePath()/resolvePageKey()/switchLocalePath()
  helpers (the last one already shaped for MITHOME-115).
- src/lib/payload-content.ts: Local API getters that also unwrap
  Payload's `{ value: string }[]` array-field shape back into plain
  string[] (see src/globals/fields/stringArray.ts) — keeps the page
  JSX consuming the exact shape the old content/types.ts had, so the
  migration is a data-source swap, not a markup rewrite.

Presentational split: page bodies moved to src/components/views/
(HomeView, AboutView, ServicesView, ContactView, LegalPageView — the
last one shared by both legal pages, identical shape) as prop-driven
components; the app-router page.tsx files became thin server-side
fetch + render wrappers. Header/Footer converted from importing
content directly to accepting nav/locale/content props, since they're
'use client' and can't call the Payload Local API themselves —
config/site.ts's navigation arrays became getMainNavigation(locale)/
getFooterNavigation(locale)/getFooterLegalLinks(locale) functions.

Two real, pre-existing bugs fixed along the way (not introduced by
this migration):
- Services and Contact pages' "Webmail belépés" links used the
  primary CTA's href (/kapcsolat) with target="_blank" instead of the
  actual webmail URL (home.hero.cta.secondary.href) — now correct.
- The GDPR checkbox link pointed to "/adatkezelesi-tajekoztato", which
  never matched the real privacy page route under any past URL
  scheme. contact.json's gdpr.label now carries a {privacyHref}
  placeholder that ContactView replaces with the locale-correct path
  — also fixes the adatvedelem page's own <title> tag, which
  previously read "Adatvédelmi Tájékoztató | Szolgáltatás jellemzők:"
  (a copy-paste bug using common.labels.features instead of the site
  name).

Known, accepted limitation: the outer shell layout hardcodes
<html lang="hu"> because it sits above the [locale] segment and can't
read the param — every [locale]/[slug] page's own generateMetadata is
locale-correct, but the initial lang attribute isn't. Documented as a
MITHOME-116 (SEO/hreflang) follow-up rather than restructured now.

Verified end to end in a real browser: /hu matches the
https://stage.mozdit.hu visual baseline (MITHOME-117) exactly; /en
renders with English nav/metadata (content body still Hungarian-only,
as expected — MITHOME-111/113 not done yet); /hu/kapcsolat's GDPR link
resolves to /hu/adatvedelem; dark mode still works; invalid locale
(/fr/about) and invalid slug (/hu/nemletezo-oldal) both 404 correctly;
bare "/" redirects to /hu. build/lint/tsc/test (58 passed) all clean,
including a clean production standalone-server run.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Do Siki
2026-09-10 16:15:09 +02:00
co-authored by Claude Sonnet 5
parent 594865ea9a
commit d6f3dda9e5
21 changed files with 1007 additions and 596 deletions
+321
View File
@@ -0,0 +1,321 @@
import Image from 'next/image'
import { localePath, type Locale } from '@/lib/i18n'
import type { getHomeContent, PartnerView } from '@/lib/payload-content'
type HomeViewProps = {
content: Awaited<ReturnType<typeof getHomeContent>>
partners: PartnerView[]
locale: Locale
}
// WHY hardcoded itt: a Partners collection (MITHOME-89) csak name/url/logo-t
// tárol, a szekció saját címe/alcíme sosem volt Payload-tartalom (a Home
// Globalból is szándékosan kimaradt, lásd src/globals/Home.ts) — ugyanaz a
// minta, mint a config/site.ts navigáció-feliratoknál.
const PARTNERS_COPY: Record<Locale, { title: string; subtitle: string }> = {
hu: { title: 'Partnereink', subtitle: 'Akikkel együtt dolgozunk' },
en: { title: 'Our Partners', subtitle: 'Who we work with' },
}
export default function HomeView({ content: pageContent, partners, locale }: HomeViewProps) {
const contactHref = localePath(locale, 'contact')
const partnersCopy = PARTNERS_COPY[locale]
return (
<div className="space-y-0">
{/* Hero Section */}
<section className="bg-gradient-hero py-20 lg:py-28 relative overflow-hidden">
{/* Background decoration */}
<div className="absolute inset-0 overflow-hidden pointer-events-none">
<div
className="absolute -top-40 -right-40 w-80 h-80 rounded-full opacity-30 animate-pulse-slow"
style={{ background: 'var(--color-primary-200)' }}
/>
<div
className="absolute -bottom-40 -left-40 w-96 h-96 rounded-full opacity-20 animate-pulse-slow"
style={{ background: 'var(--color-accent-200)', animationDelay: '1s' }}
/>
</div>
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center relative z-10">
<h1
className="text-4xl md:text-5xl lg:text-6xl font-bold mb-6 leading-tight animate-fade-in-up"
style={{ color: 'var(--color-foreground)' }}
>
{pageContent.hero.title}
</h1>
<p
className="text-lg md:text-xl max-w-4xl mx-auto mb-8 leading-relaxed animate-fade-in-up"
style={{ color: 'var(--color-foreground-muted)', animationDelay: '100ms' }}
>
{pageContent.hero.description}
</p>
{pageContent.hero.trustBullets && (
<div
className="flex flex-wrap justify-center gap-4 md:gap-8 mb-10 text-sm font-medium animate-fade-in-up"
style={{ color: 'var(--color-foreground-secondary)', animationDelay: '150ms' }}
>
{pageContent.hero.trustBullets.map((bullet: string, i: number) => (
<div key={i} className="flex items-center gap-2">
<span style={{ color: 'var(--color-primary-500)' }}>✓</span>
{bullet}
</div>
))}
</div>
)}
<div
className="flex flex-col sm:flex-row gap-4 justify-center items-center animate-fade-in-up"
style={{ animationDelay: '200ms' }}
>
<a
href={pageContent.hero.cta.primary.href}
target={pageContent.hero.cta.primary.external ? '_blank' : undefined}
rel={pageContent.hero.cta.primary.external ? 'noopener noreferrer' : undefined}
className="btn btn-primary text-lg px-8 py-4 group"
>
<svg
className="w-5 h-5 transition-transform duration-200 group-hover:scale-110"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10" />
</svg>
{pageContent.hero.cta.primary.text}
</a>
{pageContent.hero.cta.secondary && (
<a
href={pageContent.hero.cta.secondary.href}
className="btn btn-secondary text-lg px-8 py-4"
>
{pageContent.hero.cta.secondary.text}
</a>
)}
</div>
</div>
</section>
{/* USP Section */}
<section
className="py-20"
style={{ background: 'var(--color-background-secondary)' }}
>
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div className="text-center mb-12">
<h2
className="text-3xl md:text-4xl font-bold mb-4"
style={{ color: 'var(--color-foreground)' }}
>
{pageContent.about.title}
</h2>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 stagger-children">
{(pageContent.about.usps ?? []).map((usp, index) => (
<div
key={usp.id}
className="group text-center p-6 rounded-xl transition-all duration-300 hover-lift animate-fade-in-up"
style={{
background: 'var(--color-background)',
border: '1px solid var(--color-border)',
animationDelay: `${index * 100}ms`
}}
>
<div
className="icon-container icon-container-lg mx-auto mb-4"
>
<span className="text-2xl">{usp.icon}</span>
</div>
<h3
className="text-lg font-semibold mb-2 transition-colors duration-200"
style={{ color: 'var(--color-foreground)' }}
>
{usp.title}
</h3>
<p style={{ color: 'var(--color-foreground-muted)' }}>
{usp.description}
</p>
</div>
))}
</div>
</div>
</section>
{/* Services Section */}
<section
className="py-20"
style={{ background: 'var(--color-background)' }}
>
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div className="text-center mb-12">
<h2
className="text-3xl md:text-4xl font-bold mb-4"
style={{ color: 'var(--color-foreground)' }}
>
{pageContent.services.title}
</h2>
<p
className="text-lg max-w-3xl mx-auto"
style={{ color: 'var(--color-foreground-muted)' }}
>
{pageContent.services.subtitle}
</p>
</div>
<div className="grid grid-cols-1 md:grid-cols-3 gap-8 max-w-5xl mx-auto">
{pageContent.services.items.map((service, index) => (
<div
key={service.id}
className="group card hover-lift"
style={{ animationDelay: `${index * 100}ms` }}
>
<div className="icon-container mb-4">
<span className="text-xl">{service.icon}</span>
</div>
<h3
className="text-xl font-semibold mb-3 transition-colors duration-200 group-hover:text-blue-600"
style={{ color: 'var(--color-foreground)' }}
>
{service.title}
</h3>
<p
className="leading-relaxed mb-4"
style={{ color: 'var(--color-foreground-muted)' }}
>
{service.description}
</p>
<div className="mb-4">
<h4
className="text-sm font-semibold mb-2"
style={{ color: 'var(--color-foreground-secondary)' }}
>
{pageContent.serviceFeatures.title}
</h4>
<ul
className="text-sm space-y-1.5"
style={{ color: 'var(--color-foreground-muted)' }}
>
{service.features.map((feature, idx) => (
<li key={idx} className="flex items-start group/item">
<span
className="mr-2 transition-transform duration-200 group-hover/item:scale-125"
style={{ color: 'var(--color-success-500)' }}
>
✓
</span>
{feature}
</li>
))}
</ul>
</div>
<a
href={contactHref}
className="inline-flex items-center font-medium transition-all duration-200 group/link"
style={{ color: 'var(--color-primary-600)' }}
>
{service.ctaText}
<svg
className="w-4 h-4 ml-1 transition-transform duration-200 group-hover/link:translate-x-1"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
</svg>
</a>
</div>
))}
</div>
</div>
</section>
{/* Partners Section */}
{partners.length > 0 && (
<section className="py-16">
<div className="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8">
<h2 className="text-3xl font-bold text-center mb-3" style={{ color: 'var(--color-foreground)' }}>
{partnersCopy.title}
</h2>
<p className="text-center mb-10" style={{ color: 'var(--color-foreground-muted)' }}>
{partnersCopy.subtitle}
</p>
<div className="flex flex-wrap justify-center items-center gap-10">
{partners.map((partner) => (
<a
key={partner.name}
href={partner.url}
target="_blank"
rel="noopener noreferrer"
className="group flex flex-col items-center gap-3 opacity-80 hover:opacity-100 transition-opacity duration-200"
title={partner.name}
>
<span className="relative h-12 w-40">
<Image
src={partner.logo.url}
alt={partner.logo.alt}
fill
sizes="160px"
className="object-contain"
/>
</span>
<span className="text-sm" style={{ color: 'var(--color-foreground-muted)' }}>
{partner.name}
</span>
</a>
))}
</div>
</div>
</section>
)}
{/* CTA Section */}
<section
className="py-20 relative overflow-hidden"
style={{ background: 'var(--color-foreground)' }}
>
{/* Animated background elements */}
<div className="absolute inset-0 overflow-hidden pointer-events-none opacity-10">
<div
className="absolute top-10 left-10 w-32 h-32 rounded-full animate-float"
style={{ background: 'var(--color-primary-500)' }}
/>
<div
className="absolute bottom-10 right-20 w-24 h-24 rounded-full animate-float"
style={{ background: 'var(--color-accent-500)', animationDelay: '0.5s' }}
/>
<div
className="absolute top-1/2 right-1/4 w-16 h-16 rounded-full animate-float"
style={{ background: 'var(--color-primary-400)', animationDelay: '1s' }}
/>
</div>
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center relative z-10">
<h2
className="text-3xl md:text-4xl font-bold mb-4"
style={{ color: 'var(--color-background)' }}
>
{pageContent.cta.title}
</h2>
<p
className="text-xl mb-8 max-w-2xl mx-auto"
style={{ color: 'var(--color-background)', opacity: 0.8 }}
>
{pageContent.cta.subtitle}
</p>
<a
href={contactHref}
className="btn btn-primary text-lg px-8 py-4 hover-glow"
>
{pageContent.cta.button}
<svg
className="w-5 h-5 ml-2"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 8l4 4m0 0l-4 4m4-4H3" />
</svg>
</a>
</div>
</section>
</div>
)
}