Make the homepage's main marketing text blocks editable

Extends the CMS work (Phase 5) to the content the user pointed out was
still missing, using the YouTube section as the concrete example: text,
alignment, and the button link weren't editable anywhere. Rather than
patch that one section, this builds the reusable pattern the user asked
for and applies it to every comparable text block on the homepage:
hero (text only, its two nav buttons stay fixed), the YouTube section,
the craft and consultation blocks, the gallery intro, and the "more
than car-hifi" block.

New home_sections table (bilingual DE/EN, like faqs, since the site has
a language switcher) + HomeSectionController, following the same
DB-row-with-built-in-defaults pattern as legal_pages: a section not yet
customized returns the exact text that used to be hard-coded in the
i18n dictionary, so nothing on a live site goes blank. New "Startseite"
admin page (content.manage, alongside FAQ) with per-section DE/EN tabs,
reusing the Phase 4 RichTextEditor for the body text and a plain
alignment dropdown. Wired into export/import (Settings -> Export &
Import) alongside the other content sections.

Alignment is applied via fixed left/center/right class lookup tables in
Home.jsx rather than a template-string class name, since Tailwind's
build-time scanner needs literal class names present in the source to
avoid purging them from the production CSS.

Known trade-off: two sections (hero, "more than car-hifi") previously
had hand-tuned responsive alignment that differed by breakpoint
(e.g. centered on mobile, left-aligned on desktop for "more"). Making
alignment a single admin-editable value necessarily replaces that with
one fixed choice at every breakpoint - simpler to reason about and
control, at the cost of that responsive nuance.

Verified end-to-end against the local database directly via PHP CLI
(bypassing a local Apache path-routing quirk unrelated to this change):
confirmed defaults come back correctly before any row exists, and that
saving and reading back a row round-trips correctly - then removed the
test row before finishing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Maaxxs 2026-09-09 02:51:00 +02:00
parent 3ea5bd4201
commit ba4fa986d3
15 changed files with 603 additions and 115 deletions

View file

@ -31,6 +31,7 @@ import GalleryPhotos from './pages/admin/GalleryPhotos.jsx';
import Packages from './pages/admin/Packages.jsx'; import Packages from './pages/admin/Packages.jsx';
import Services from './pages/admin/Services.jsx'; import Services from './pages/admin/Services.jsx';
import Faqs from './pages/admin/Faqs.jsx'; import Faqs from './pages/admin/Faqs.jsx';
import HomeSections from './pages/admin/HomeSections.jsx';
import PackageProducts from './pages/admin/PackageProducts.jsx'; import PackageProducts from './pages/admin/PackageProducts.jsx';
import PackageUpgrades from './pages/admin/PackageUpgrades.jsx'; import PackageUpgrades from './pages/admin/PackageUpgrades.jsx';
import ContactRequests from './pages/admin/ContactRequests.jsx'; import ContactRequests from './pages/admin/ContactRequests.jsx';
@ -87,6 +88,7 @@ export default function App() {
<Route path="packages/:packageId/upgrades" element={<RequirePermission permission="packages.manage"><PackageUpgrades /></RequirePermission>} /> <Route path="packages/:packageId/upgrades" element={<RequirePermission permission="packages.manage"><PackageUpgrades /></RequirePermission>} />
<Route path="services" element={<RequirePermission permission="services.manage"><Services /></RequirePermission>} /> <Route path="services" element={<RequirePermission permission="services.manage"><Services /></RequirePermission>} />
<Route path="faqs" element={<RequirePermission permission="content.manage"><Faqs /></RequirePermission>} /> <Route path="faqs" element={<RequirePermission permission="content.manage"><Faqs /></RequirePermission>} />
<Route path="home-sections" element={<RequirePermission permission="content.manage"><HomeSections /></RequirePermission>} />
<Route path="contact-requests" element={<RequirePermission permission="contact.manage"><ContactRequests /></RequirePermission>} /> <Route path="contact-requests" element={<RequirePermission permission="contact.manage"><ContactRequests /></RequirePermission>} />
<Route path="users" element={<RequirePermission permission="users.manage"><AdminUsers /></RequirePermission>} /> <Route path="users" element={<RequirePermission permission="users.manage"><AdminUsers /></RequirePermission>} />
<Route path="permission-groups" element={<RequirePermission permission="permission_groups.manage"><PermissionGroups /></RequirePermission>} /> <Route path="permission-groups" element={<RequirePermission permission="permission_groups.manage"><PermissionGroups /></RequirePermission>} />

View file

@ -57,6 +57,7 @@ export default function AdminLayout() {
{ {
title: 'Website', title: 'Website',
links: [ links: [
{ to: '/admin/home-sections', label: 'Startseite', icon: 'home', permission: 'content.manage' },
{ to: '/admin/services', label: 'Leistungen', icon: 'briefcase', permission: 'services.manage' }, { to: '/admin/services', label: 'Leistungen', icon: 'briefcase', permission: 'services.manage' },
{ to: '/admin/faqs', label: 'FAQ', icon: 'help', permission: 'content.manage' }, { to: '/admin/faqs', label: 'FAQ', icon: 'help', permission: 'content.manage' },
], ],

View file

@ -0,0 +1,198 @@
import { useEffect, useState } from 'react';
import { api } from '../../api/client.js';
import RichTextEditor from '../../components/RichTextEditor.jsx';
const SECTIONS = [
{ slug: 'hero', label: 'Hero (ganz oben)' },
{ slug: 'youtube', label: 'YouTube-Sektion' },
{ slug: 'craft', label: 'Handwerk' },
{ slug: 'advice', label: 'Beratung' },
{ slug: 'insights', label: 'Einblicke (Bildergalerie-Intro)' },
{ slug: 'more', label: 'Mehr als Car-Hifi' },
];
const ALIGN_OPTIONS = [
{ value: 'left', label: 'Links' },
{ value: 'center', label: 'Mittig' },
{ value: 'right', label: 'Rechts' },
];
export default function HomeSections() {
const [sections, setSections] = useState(null);
const [activeSlug, setActiveSlug] = useState('hero');
const [activeLang, setActiveLang] = useState('de');
const [saveBusy, setSaveBusy] = useState(false);
const [saveError, setSaveError] = useState('');
const [saveSuccess, setSaveSuccess] = useState(false);
useEffect(() => {
api.get('/home-sections').then(setSections);
}, []);
if (!sections) {
return <p className="text-sm text-neutral-400">Lädt…</p>;
}
const active = sections[activeSlug];
const update = (field, value) => {
setSections((s) => ({ ...s, [activeSlug]: { ...s[activeSlug], [field]: value } }));
setSaveSuccess(false);
};
const handleSave = async () => {
setSaveBusy(true);
setSaveError('');
setSaveSuccess(false);
try {
await api.put(`/home-sections/${activeSlug}`, active);
setSaveSuccess(true);
} catch (err) {
setSaveError(err.message);
} finally {
setSaveBusy(false);
}
};
return (
<div className="max-w-3xl space-y-6">
<div>
<h1 className="mb-1 text-xl font-bold text-neutral-900 dark:text-white">Startseite</h1>
<p className="mb-4 text-sm text-neutral-500 dark:text-neutral-400">
Text, Ausrichtung und (falls vorhanden) Button-Ziel der wichtigsten Textabschnitte auf der
Startseite. Bilder, Statistik-Kacheln, Marken-Streifen, Bewertungen und FAQ werden an anderer
Stelle verwaltet.
</p>
</div>
<div className="rounded-xl border border-neutral-200 bg-white p-6 dark:border-neutral-800 dark:bg-neutral-900">
<div className="mb-4 flex flex-wrap gap-2">
{SECTIONS.map((s) => (
<button
key={s.slug}
type="button"
onClick={() => {
setActiveSlug(s.slug);
setSaveSuccess(false);
setSaveError('');
}}
className={`rounded-md px-3 py-1.5 text-sm font-medium transition ${
activeSlug === s.slug
? 'bg-brand-500 text-white'
: 'border border-neutral-300 text-neutral-600 hover:bg-neutral-100 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-800'
}`}
>
{s.label}
</button>
))}
</div>
<div className="mb-4 flex items-center justify-between gap-4 border-b border-neutral-200 pb-4 dark:border-neutral-800">
<div className="flex gap-1">
{[
['de', 'Deutsch'],
['en', 'English'],
].map(([lang, label]) => (
<button
key={lang}
type="button"
onClick={() => setActiveLang(lang)}
className={`rounded-md px-3 py-1 text-sm font-medium transition ${
activeLang === lang
? 'bg-neutral-800 text-white dark:bg-neutral-100 dark:text-neutral-900'
: 'text-neutral-500 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:bg-neutral-800'
}`}
>
{label}
</button>
))}
</div>
<div className="flex items-center gap-2">
<label className="text-sm font-medium text-neutral-700 dark:text-neutral-300">Ausrichtung</label>
<select
value={active.text_align}
onChange={(e) => update('text_align', e.target.value)}
className="rounded-md border border-neutral-300 bg-white px-2 py-1 text-sm dark:border-neutral-700 dark:bg-neutral-900"
>
{ALIGN_OPTIONS.map((a) => (
<option key={a.value} value={a.value}>
{a.label}
</option>
))}
</select>
</div>
</div>
<div className="space-y-3">
<div>
<label className="mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300">
Kurzer Vorspann (optional)
</label>
<input
value={active[`eyebrow_${activeLang}`] || ''}
onChange={(e) => update(`eyebrow_${activeLang}`, e.target.value)}
className="w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"
/>
</div>
<div>
<label className="mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300">Überschrift</label>
<input
value={active[`title_${activeLang}`] || ''}
onChange={(e) => update(`title_${activeLang}`, e.target.value)}
className="w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"
/>
</div>
<RichTextEditor
label="Text"
value={active[`body_html_${activeLang}`] || ''}
onChange={(html) => update(`body_html_${activeLang}`, html)}
/>
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
<div>
<label className="mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300">
Button-Beschriftung (optional)
</label>
<input
value={active[`button_label_${activeLang}`] || ''}
onChange={(e) => update(`button_label_${activeLang}`, e.target.value)}
className="w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"
/>
</div>
<div>
<label className="mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300">
Button-Ziel (Link, für beide Sprachen gleich)
</label>
<input
value={active.button_url || ''}
onChange={(e) => update('button_url', e.target.value)}
placeholder="/leistungen oder https://…"
className="w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"
/>
<p className="mt-1 text-xs text-neutral-400">
Ohne Beschriftung UND Ziel wird kein Button angezeigt. Mit "/" beginnende Ziele bleiben
innerhalb der Seite, alles andere öffnet extern in einem neuen Tab.
</p>
</div>
</div>
</div>
{active.updated_at && (
<p className="mt-3 text-xs text-neutral-400">
Zuletzt geändert: {new Date(active.updated_at.replace(' ', 'T')).toLocaleString('de-DE')}
</p>
)}
{saveError && <p className="mt-3 text-sm text-red-600">{saveError}</p>}
{saveSuccess && <p className="mt-3 text-sm text-green-600 dark:text-green-400">Gespeichert.</p>}
<button
type="button"
onClick={handleSave}
disabled={saveBusy}
className="mt-4 rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600 disabled:opacity-50"
>
{saveBusy ? 'Speichere…' : 'Speichern'}
</button>
</div>
</div>
);
}

View file

@ -31,6 +31,12 @@ const SECTIONS = [
hint: 'Impressum, Datenschutzerklärung, AGB', hint: 'Impressum, Datenschutzerklärung, AGB',
tables: ['legal_pages'], tables: ['legal_pages'],
}, },
{
key: 'home',
label: 'Startseiten-Texte',
hint: 'Hero, YouTube-Sektion, Handwerk, Beratung, Einblicke, "Mehr als Car-Hifi"',
tables: ['home_sections'],
},
{ {
key: 'permissions', key: 'permissions',
label: 'Berechtigungsgruppen', label: 'Berechtigungsgruppen',
@ -52,6 +58,7 @@ const TABLE_LABELS = {
gallery_photos: 'Galerie-Fotos', gallery_photos: 'Galerie-Fotos',
app_settings: 'Einstellungen', app_settings: 'Einstellungen',
legal_pages: 'Rechtstexte', legal_pages: 'Rechtstexte',
home_sections: 'Startseiten-Texte',
permission_groups: 'Berechtigungsgruppen', permission_groups: 'Berechtigungsgruppen',
permission_group_permissions: 'Berechtigungsgruppen-Rechte', permission_group_permissions: 'Berechtigungsgruppen-Rechte',
admin_users: 'Benutzerkonten', admin_users: 'Benutzerkonten',

View file

@ -19,11 +19,40 @@ import galleryRear from '../../assets/photos/gallery-rear.webp';
import heroHighlight from '../../assets/leistungen/hero-highlight.webp'; import heroHighlight from '../../assets/leistungen/hero-highlight.webp';
import youtubeVideo from '../../assets/videos/youtube-hintergrund.mp4'; import youtubeVideo from '../../assets/videos/youtube-hintergrund.mp4';
const YOUTUBE_URL = 'https://www.youtube.com/@hifiplanet2812';
const YOUTUBE_VIDEO_ID = 'ostj2mKDVUc';
const brands = ['Ground Zero Audio', 'Audison', 'Hertz', 'Helix', 'Brax', 'Gladen', 'Alpine', 'Pioneer', 'Kenwood', 'JVC']; const brands = ['Ground Zero Audio', 'Audison', 'Hertz', 'Helix', 'Brax', 'Gladen', 'Alpine', 'Pioneer', 'Kenwood', 'JVC'];
// Tailwinds Build-Zeit-Scanner braucht die vollstaendigen Klassennamen woertlich im
// Quellcode - ein dynamisch zusammengesetzter String wie `text-${align}` wuerde nicht
// erkannt und aus dem Production-CSS herausgefiltert. Deshalb feste Lookup-Tabellen statt
// Template-Strings, angesteuert ueber home_sections.text_align (siehe HomeSectionController).
const ALIGN_TEXT = { left: 'text-left', center: 'text-center', right: 'text-right' };
const ALIGN_ITEMS = { left: 'items-start', center: 'items-center', right: 'items-end' };
const ALIGN_JUSTIFY = { left: 'justify-start', center: 'justify-center', right: 'justify-end' };
const ALIGN_MARGIN_X = { left: '', center: 'mx-auto', right: 'ml-auto' };
const EMPTY_SECTION = {
eyebrow_de: '', eyebrow_en: '', title_de: '', title_en: '', body_html_de: '', body_html_en: '',
text_align: 'center', button_label_de: '', button_label_en: '', button_url: '',
};
/** Rendert nur, wenn sowohl Beschriftung als auch Ziel gesetzt sind - interne Ziele (mit "/")
* bleiben in der SPA, alles andere oeffnet extern in einem neuen Tab. */
function SectionButton({ label, url, className }) {
if (!label || !url) return null;
if (url.startsWith('/')) {
return (
<Link to={url} className={className}>
{label}
</Link>
);
}
return (
<a href={url} target="_blank" rel="noopener noreferrer" className={className}>
{label}
</a>
);
}
// Native Pixelmasse der Bilder unten - nur fuer die width/height-Attribute auf <img>, // Native Pixelmasse der Bilder unten - nur fuer die width/height-Attribute auf <img>,
// damit der Browser vor dem Laden Platz reserviert (verhindert Layout-Sprung). Die // damit der Browser vor dem Laden Platz reserviert (verhindert Layout-Sprung). Die
// tatsaechliche Anzeigegroesse wird weiterhin komplett per CSS (aspect-square etc.) // tatsaechliche Anzeigegroesse wird weiterhin komplett per CSS (aspect-square etc.)
@ -46,6 +75,23 @@ export default function Home() {
const galleryAlts = t('home.galleryAlts'); const galleryAlts = t('home.galleryAlts');
const gallery = galleryImages.map((img, i) => ({ ...img, alt: galleryAlts[i] })); const gallery = galleryImages.map((img, i) => ({ ...img, alt: galleryAlts[i] }));
const [faqs, setFaqs] = useState([]); const [faqs, setFaqs] = useState([]);
const [homeSections, setHomeSections] = useState({});
// Kurzform, um pro Abschnitt Text/Ausrichtung/Button in der jeweils aktiven Sprache zu lesen.
const section = (slug) => {
const s = homeSections[slug] || EMPTY_SECTION;
return {
eyebrow: s[`eyebrow_${language}`] || '',
title: s[`title_${language}`] || '',
bodyHtml: s[`body_html_${language}`] || '',
align: s.text_align || 'center',
buttonLabel: s[`button_label_${language}`] || '',
buttonUrl: s.button_url || '',
};
};
useEffect(() => {
api.get('/home-sections').then(setHomeSections).catch(() => {});
}, []);
// Solange noch keine Google-Rezensionen konfiguriert/erfolgreich abgerufen wurden // Solange noch keine Google-Rezensionen konfiguriert/erfolgreich abgerufen wurden
// (googleReviews === null), zeigt die Seite die festen Beispiel-Texte aus den // (googleReviews === null), zeigt die Seite die festen Beispiel-Texte aus den
// Uebersetzungen - danach die echten, im Admin-Bereich zwischengespeicherten Rezensionen. // Uebersetzungen - danach die echten, im Admin-Bereich zwischengespeicherten Rezensionen.
@ -154,23 +200,26 @@ export default function Home() {
<motion.div <motion.div
style={{ y: heroTextY, opacity: heroOpacity }} style={{ y: heroTextY, opacity: heroOpacity }}
className="relative flex h-full max-w-6xl flex-col items-center justify-center px-4 mx-auto text-center sm:px-6" className={`relative flex h-full max-w-6xl flex-col ${ALIGN_ITEMS[section('hero').align]} justify-center px-4 mx-auto ${ALIGN_TEXT[section('hero').align]} sm:px-6`}
> >
<motion.div <motion.div
initial={{ opacity: 0, y: 20 }} initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }} animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.7, ease: 'easeOut' }} transition={{ duration: 0.7, ease: 'easeOut' }}
> >
<p className="mb-3 text-sm font-semibold uppercase tracking-wide text-brand-400"> {section('hero').eyebrow && (
{t('home.welcome')} <p className="mb-3 text-sm font-semibold uppercase tracking-wide text-brand-400">
</p> {section('hero').eyebrow}
</p>
)}
<h1 className="text-3xl font-extrabold tracking-tight text-white sm:text-5xl"> <h1 className="text-3xl font-extrabold tracking-tight text-white sm:text-5xl">
{t('home.heroTitle')} {section('hero').title}
</h1> </h1>
<p className="mx-auto mt-4 max-w-2xl text-base text-neutral-200 sm:text-lg"> <div
{t('home.heroSubtitle')} className={`legal-content mt-4 max-w-2xl text-base text-neutral-200 sm:text-lg ${ALIGN_MARGIN_X[section('hero').align]}`}
</p> dangerouslySetInnerHTML={{ __html: section('hero').bodyHtml }}
<div className="mt-8 flex flex-wrap items-center justify-center gap-3"> />
<div className={`mt-8 flex flex-wrap items-center ${ALIGN_JUSTIFY[section('hero').align]} gap-3`}>
<Link <Link
to="/fahrzeuge" to="/fahrzeuge"
className="rounded-md bg-brand-500 px-6 py-3 text-sm font-semibold text-white shadow-sm transition hover:-translate-y-0.5 hover:bg-brand-600 hover:shadow-lg" className="rounded-md bg-brand-500 px-6 py-3 text-sm font-semibold text-white shadow-sm transition hover:-translate-y-0.5 hover:bg-brand-600 hover:shadow-lg"
@ -227,24 +276,24 @@ export default function Home() {
</video> </video>
<div className="absolute inset-0 bg-black/55" /> <div className="absolute inset-0 bg-black/55" />
<Reveal className="relative mx-auto max-w-3xl px-4 text-center sm:px-6"> <Reveal className={`relative mx-auto max-w-3xl px-4 ${ALIGN_TEXT[section('youtube').align]} sm:px-6`}>
<p className="mb-4 text-xs font-semibold uppercase tracking-[0.2em] text-neutral-200 sm:text-sm"> {section('youtube').eyebrow && (
{t('home.youtubeBadge')} <p className="mb-4 text-xs font-semibold uppercase tracking-[0.2em] text-neutral-200 sm:text-sm">
</p> {section('youtube').eyebrow}
</p>
)}
<h2 className="text-3xl font-bold uppercase tracking-wide text-white sm:text-5xl"> <h2 className="text-3xl font-bold uppercase tracking-wide text-white sm:text-5xl">
{t('home.youtubeTitle')} {section('youtube').title}
</h2> </h2>
<p className="mt-4 text-xs font-semibold uppercase tracking-wide text-neutral-200 sm:text-sm"> <div
{t('home.youtubeText')} className="legal-content mt-4 text-xs font-semibold uppercase tracking-wide text-neutral-200 sm:text-sm"
</p> dangerouslySetInnerHTML={{ __html: section('youtube').bodyHtml }}
<a />
href={`https://www.youtube.com/watch?v=${YOUTUBE_VIDEO_ID}`} <SectionButton
target="_blank" label={section('youtube').buttonLabel}
rel="noopener noreferrer" url={section('youtube').buttonUrl}
className="mt-8 inline-flex items-center justify-center rounded-full bg-white px-8 py-3 text-xs font-bold uppercase tracking-wide text-neutral-900 transition hover:-translate-y-0.5 hover:bg-neutral-100" className="mt-8 inline-flex items-center justify-center rounded-full bg-white px-8 py-3 text-xs font-bold uppercase tracking-wide text-neutral-900 transition hover:-translate-y-0.5 hover:bg-neutral-100"
> />
{t('home.youtubeCta')}
</a>
</Reveal> </Reveal>
</section> </section>
@ -261,22 +310,28 @@ export default function Home() {
style={{ maxHeight: 380 }} style={{ maxHeight: 380 }}
/> />
</Reveal> </Reveal>
<Reveal direction="right" index={1}> <Reveal direction="right" index={1} className={ALIGN_TEXT[section('craft').align]}>
<p className="mb-2 text-sm font-semibold uppercase tracking-wide text-brand-600 dark:text-brand-400">{t('home.craftEyebrow')}</p> {section('craft').eyebrow && (
<h2 className="mb-3 text-2xl font-bold text-neutral-900 dark:text-white">{t('home.craftTitle')}</h2> <p className="mb-2 text-sm font-semibold uppercase tracking-wide text-brand-600 dark:text-brand-400">{section('craft').eyebrow}</p>
<p className="text-neutral-600 dark:text-neutral-300"> )}
{t('home.craftText')} <h2 className="mb-3 text-2xl font-bold text-neutral-900 dark:text-white">{section('craft').title}</h2>
</p> <div
className="legal-content text-neutral-600 dark:text-neutral-300"
dangerouslySetInnerHTML={{ __html: section('craft').bodyHtml }}
/>
</Reveal> </Reveal>
</div> </div>
<div className="grid items-center gap-8 md:grid-cols-2"> <div className="grid items-center gap-8 md:grid-cols-2">
<Reveal direction="left" className="order-2 md:order-1"> <Reveal direction="left" className={`order-2 md:order-1 ${ALIGN_TEXT[section('advice').align]}`}>
<p className="mb-2 text-sm font-semibold uppercase tracking-wide text-brand-600 dark:text-brand-400">{t('home.adviceEyebrow')}</p> {section('advice').eyebrow && (
<h2 className="mb-3 text-2xl font-bold text-neutral-900 dark:text-white">{t('home.adviceTitle')}</h2> <p className="mb-2 text-sm font-semibold uppercase tracking-wide text-brand-600 dark:text-brand-400">{section('advice').eyebrow}</p>
<p className="text-neutral-600 dark:text-neutral-300"> )}
{t('home.adviceText')} <h2 className="mb-3 text-2xl font-bold text-neutral-900 dark:text-white">{section('advice').title}</h2>
</p> <div
className="legal-content text-neutral-600 dark:text-neutral-300"
dangerouslySetInnerHTML={{ __html: section('advice').bodyHtml }}
/>
</Reveal> </Reveal>
<Reveal direction="right" index={1} shine className="order-1 md:order-2 rounded-xl shadow-lg"> <Reveal direction="right" index={1} shine className="order-1 md:order-2 rounded-xl shadow-lg">
<img <img
@ -293,11 +348,15 @@ export default function Home() {
</section> </section>
<section className="mx-auto max-w-6xl px-4 py-16 sm:px-6"> <section className="mx-auto max-w-6xl px-4 py-16 sm:px-6">
<Reveal className="mb-8 text-center"> <Reveal className={`mb-8 ${ALIGN_TEXT[section('insights').align]}`}>
<h2 className="text-2xl font-bold text-neutral-900 dark:text-white">{t('home.insightsTitle')}</h2> {section('insights').eyebrow && (
<p className="mt-2 text-neutral-600 dark:text-neutral-300"> <p className="mb-2 text-sm font-semibold uppercase tracking-wide text-brand-600 dark:text-brand-400">{section('insights').eyebrow}</p>
{t('home.insightsText')} )}
</p> <h2 className="text-2xl font-bold text-neutral-900 dark:text-white">{section('insights').title}</h2>
<div
className="legal-content mt-2 text-neutral-600 dark:text-neutral-300"
dangerouslySetInnerHTML={{ __html: section('insights').bodyHtml }}
/>
</Reveal> </Reveal>
<div className="grid grid-cols-2 gap-3 sm:grid-cols-3"> <div className="grid grid-cols-2 gap-3 sm:grid-cols-3">
{gallery.map((img, i) => ( {gallery.map((img, i) => (
@ -355,18 +414,21 @@ export default function Home() {
<Reveal <Reveal
direction="right" direction="right"
index={1} index={1}
className="rounded-xl border border-neutral-200 bg-white p-8 text-center shadow-sm dark:border-neutral-800 dark:bg-neutral-900 md:text-left" className={`rounded-xl border border-neutral-200 bg-white p-8 shadow-sm dark:border-neutral-800 dark:bg-neutral-900 ${ALIGN_TEXT[section('more').align]}`}
> >
<h2 className="mb-3 text-2xl font-bold text-neutral-900 dark:text-white">{t('home.moreTitle')}</h2> {section('more').eyebrow && (
<p className="mx-auto mb-8 max-w-2xl text-neutral-600 dark:text-neutral-300 md:mx-0"> <p className="mb-2 text-sm font-semibold uppercase tracking-wide text-brand-600 dark:text-brand-400">{section('more').eyebrow}</p>
{t('home.moreText')} )}
</p> <h2 className="mb-3 text-2xl font-bold text-neutral-900 dark:text-white">{section('more').title}</h2>
<Link <div
to="/leistungen" className={`legal-content mb-8 max-w-2xl text-neutral-600 dark:text-neutral-300 ${ALIGN_MARGIN_X[section('more').align]}`}
dangerouslySetInnerHTML={{ __html: section('more').bodyHtml }}
/>
<SectionButton
label={section('more').buttonLabel}
url={section('more').buttonUrl}
className="inline-block rounded-md border border-neutral-300 px-6 py-3 text-sm font-semibold text-neutral-700 transition hover:-translate-y-0.5 hover:bg-neutral-100 dark:border-neutral-700 dark:text-neutral-200 dark:hover:bg-neutral-800" className="inline-block rounded-md border border-neutral-300 px-6 py-3 text-sm font-semibold text-neutral-700 transition hover:-translate-y-0.5 hover:bg-neutral-100 dark:border-neutral-700 dark:text-neutral-200 dark:hover:bg-neutral-800"
> />
{t('home.moreCta')}
</Link>
</Reveal> </Reveal>
</div> </div>
</section> </section>

View file

@ -0,0 +1,23 @@
USE hifi_shop;
-- Die wichtigsten Text-Abschnitte der Startseite (YouTube-Sektion, Handwerk/Beratung,
-- Einblicke, "Mehr als Car-Hifi") als editierbare Bloecke statt hart im JSX codiert.
-- Zweisprachig (DE/EN, wie bei faqs), da die Seite einen Sprachumschalter hat.
-- Fehlt eine Zeile fuer einen Slug, liefert HomeSectionController einen eingebauten
-- Standardtext (siehe DEFAULTS dort - identisch zum bisherigen i18n-Text).
CREATE TABLE IF NOT EXISTS home_sections (
id INT AUTO_INCREMENT PRIMARY KEY,
slug VARCHAR(50) NOT NULL UNIQUE,
eyebrow_de VARCHAR(150) NULL,
eyebrow_en VARCHAR(150) NULL,
title_de VARCHAR(255) NULL,
title_en VARCHAR(255) NULL,
body_html_de TEXT NULL,
body_html_en TEXT NULL,
text_align ENUM('left','center','right') NOT NULL DEFAULT 'center',
button_label_de VARCHAR(100) NULL,
button_label_en VARCHAR(100) NULL,
button_url VARCHAR(500) NULL,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB;

View file

@ -59,6 +59,22 @@ CREATE TABLE legal_pages (
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB; ) ENGINE=InnoDB;
CREATE TABLE home_sections (
id INT AUTO_INCREMENT PRIMARY KEY,
slug VARCHAR(50) NOT NULL UNIQUE,
eyebrow_de VARCHAR(150) NULL,
eyebrow_en VARCHAR(150) NULL,
title_de VARCHAR(255) NULL,
title_en VARCHAR(255) NULL,
body_html_de TEXT NULL,
body_html_en TEXT NULL,
text_align ENUM('left','center','right') NOT NULL DEFAULT 'center',
button_label_de VARCHAR(100) NULL,
button_label_en VARCHAR(100) NULL,
button_url VARCHAR(500) NULL,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB;
CREATE TABLE services ( CREATE TABLE services (
id INT AUTO_INCREMENT PRIMARY KEY, id INT AUTO_INCREMENT PRIMARY KEY,
icon_name VARCHAR(100) NOT NULL, icon_name VARCHAR(100) NOT NULL,

View file

@ -27,6 +27,7 @@ use App\Controllers\PackageUpgradeController;
use App\Controllers\PermissionCatalogController; use App\Controllers\PermissionCatalogController;
use App\Controllers\PermissionGroupController; use App\Controllers\PermissionGroupController;
use App\Controllers\ProductController; use App\Controllers\ProductController;
use App\Controllers\HomeSectionController;
use App\Controllers\PageContentController; use App\Controllers\PageContentController;
use App\Controllers\SchemaController; use App\Controllers\SchemaController;
use App\Controllers\ServiceController; use App\Controllers\ServiceController;
@ -164,6 +165,9 @@ $router->post('/faqs', $perm('content.manage', fn($p) => FaqController::store())
$router->put('/faqs/{id}', $perm('content.manage', fn($p) => FaqController::update($p))); $router->put('/faqs/{id}', $perm('content.manage', fn($p) => FaqController::update($p)));
$router->delete('/faqs/{id}', $perm('content.manage', fn($p) => FaqController::destroy($p))); $router->delete('/faqs/{id}', $perm('content.manage', fn($p) => FaqController::destroy($p)));
$router->get('/home-sections', fn($p) => HomeSectionController::index());
$router->put('/home-sections/{slug}', $perm('content.manage', fn($p) => HomeSectionController::update($p)));
// Nur der zuletzt gecachte Stand - kein Live-Aufruf bei Google pro Seitenbesuch // Nur der zuletzt gecachte Stand - kein Live-Aufruf bei Google pro Seitenbesuch
// (Aktualisierung laeuft ausschliesslich ueber refresh_google_reviews.php). // (Aktualisierung laeuft ausschliesslich ueber refresh_google_reviews.php).
$router->get('/google-reviews', fn($p) => GoogleReviewsController::publicReviews()); $router->get('/google-reviews', fn($p) => GoogleReviewsController::publicReviews());

View file

@ -0,0 +1,133 @@
<?php
namespace App\Controllers;
use App\Config\Database;
use App\Support\Http;
/**
* Die wichtigsten Text-Abschnitte der Startseite (Hero, YouTube-Sektion, Handwerk,
* Beratung, Einblicke, "Mehr als Car-Hifi") als editierbare Bloecke statt hart im JSX
* codiert - zweisprachig (DE/EN, wie bei faqs), da die Seite einen Sprachumschalter hat.
* Fester Satz von Slugs (kein Anlegen/Loeschen ueber die UI, das waere ein struktureller
* Eingriff ins Seiten-Layout). Fehlt eine Zeile in home_sections fuer einen Slug (z.B.
* frisch installierte Seite), liefert DEFAULTS denselben Text, der zuvor im
* i18n-Woerterbuch stand.
*/
class HomeSectionController
{
public const ALLOWED_SLUGS = ['hero', 'youtube', 'craft', 'advice', 'insights', 'more'];
private const DEFAULTS = [
'hero' => [
'eyebrow_de' => 'Willkommen bei HifiPlanet', 'eyebrow_en' => 'Welcome to HifiPlanet',
'title_de' => 'Home of pure Sound', 'title_en' => 'Home of pure Sound',
'body_html_de' => '<p>Dein Car-Hifi Spezialist für individuelle Sound-Umbauten. Wähle dein Fahrzeug, entdecke passende Pakete und frag unverbindlich an – wir kümmern uns um den Rest.</p>',
'body_html_en' => '<p>Your car-hifi specialist for custom sound installations. Choose your vehicle, discover the right package and get in touch, no obligation – we take care of the rest.</p>',
'text_align' => 'center',
'button_label_de' => null, 'button_label_en' => null, 'button_url' => null,
],
'youtube' => [
'eyebrow_de' => 'HifiPlanet präsentiert', 'eyebrow_en' => 'HifiPlanet presents',
'title_de' => 'Das Handwerk hinter deinem Sound', 'title_en' => 'The craft behind your sound',
'body_html_de' => '<p>Entdecke die Handwerkskunst hinter unserer Arbeit</p>',
'body_html_en' => '<p>Discover the artistry behind our work</p>',
'text_align' => 'center',
'button_label_de' => 'Jetzt ansehen', 'button_label_en' => 'Watch now',
'button_url' => 'https://www.youtube.com/watch?v=ostj2mKDVUc',
],
'craft' => [
'eyebrow_de' => 'Handwerk', 'eyebrow_en' => 'Craftsmanship',
'title_de' => 'Präzisionsarbeit in jedem Detail', 'title_en' => 'Precision work in every detail',
'body_html_de' => '<p>Ob eigens gefertigte Subwoofer-Gehäuse, integrierte Beleuchtung oder unsichtbar verlegte Kabelwege – dank eigener CNC-, Laser- und 3D-Druck-Fertigung entstehen bei uns Lösungen, die es von der Stange nicht gibt.</p>',
'body_html_en' => '<p>Whether custom-built subwoofer enclosures, integrated lighting or invisibly routed cabling – our own CNC, laser and 3D-printing production means we can build solutions you simply can\'t buy off the shelf.</p>',
'text_align' => 'left',
'button_label_de' => null, 'button_label_en' => null, 'button_url' => null,
],
'advice' => [
'eyebrow_de' => 'Beratung', 'eyebrow_en' => 'Consultation',
'title_de' => 'Von der ersten Idee bis zum letzten Schliff', 'title_en' => 'From the first idea to the final touch',
'body_html_de' => '<p>Jedes Fahrzeug und jeder Anspruch ist anders. Deshalb beraten wir dich persönlich und unverbindlich – vom dezenten Upgrade bis zum kompromisslosen High-End-System.</p>',
'body_html_en' => '<p>Every vehicle and every requirement is different. That\'s why we advise you personally and without obligation – from a subtle upgrade to an uncompromising high-end system.</p>',
'text_align' => 'left',
'button_label_de' => null, 'button_label_en' => null, 'button_url' => null,
],
'insights' => [
'eyebrow_de' => null, 'eyebrow_en' => null,
'title_de' => 'Einblicke in unsere Umbauten', 'title_en' => 'A look at our installations',
'body_html_de' => '<p>Vom unauffälligen Sound-Upgrade bis zum aufwendigen Komplettumbau – Handarbeit aus unserer Werkstatt in Amorbach.</p>',
'body_html_en' => '<p>From subtle sound upgrades to elaborate full installations – handcrafted in our workshop in Amorbach.</p>',
'text_align' => 'center',
'button_label_de' => null, 'button_label_en' => null, 'button_url' => null,
],
'more' => [
'eyebrow_de' => null, 'eyebrow_en' => null,
'title_de' => 'Mehr als nur Car-Hifi', 'title_en' => 'More than just car-hifi',
'body_html_de' => '<p>Neben individuellen Sound-Umbauten bieten wir CNC-Zerspanung, Lasertechnik, 3D-Druck und mehr – alles aus einer Hand in unserer eigenen Werkstatt.</p>',
'body_html_en' => '<p>Besides custom sound installations, we also offer CNC machining, laser technology, 3D printing and more – all from a single source in our own workshop.</p>',
'text_align' => 'left',
'button_label_de' => 'Alle Leistungen entdecken', 'button_label_en' => 'Discover all our services',
'button_url' => '/leistungen',
],
];
private const COLUMNS = [
'eyebrow_de', 'eyebrow_en', 'title_de', 'title_en', 'body_html_de', 'body_html_en',
'text_align', 'button_label_de', 'button_label_en', 'button_url',
];
/** Oeffentlich + Admin: alle Abschnitte auf einmal (DB-Stand oder Standardtext). */
public static function index(): void
{
$stmt = Database::connection()->prepare(
'SELECT ' . implode(', ', self::COLUMNS) . ', updated_at FROM home_sections WHERE slug = ?'
);
$sections = [];
foreach (self::ALLOWED_SLUGS as $slug) {
$stmt->execute([$slug]);
$row = $stmt->fetch();
$sections[$slug] = $row ?: array_merge(self::DEFAULTS[$slug], ['updated_at' => null]);
}
Http::send($sections);
}
public static function update(array $params): void
{
$slug = $params['slug'] ?? '';
if (!in_array($slug, self::ALLOWED_SLUGS, true)) {
Http::error('Unbekannter Abschnitt', 404);
}
$body = Http::jsonBody();
$align = trim($body['text_align'] ?? '') ?: 'center';
if (!in_array($align, ['left', 'center', 'right'], true)) {
$align = 'center';
}
$values = [
'eyebrow_de' => trim($body['eyebrow_de'] ?? '') ?: null,
'eyebrow_en' => trim($body['eyebrow_en'] ?? '') ?: null,
'title_de' => trim($body['title_de'] ?? '') ?: null,
'title_en' => trim($body['title_en'] ?? '') ?: null,
'body_html_de' => (string) ($body['body_html_de'] ?? ''),
'body_html_en' => (string) ($body['body_html_en'] ?? ''),
'text_align' => $align,
'button_label_de' => trim($body['button_label_de'] ?? '') ?: null,
'button_label_en' => trim($body['button_label_en'] ?? '') ?: null,
'button_url' => trim($body['button_url'] ?? '') ?: null,
];
$db = Database::connection();
$columnList = implode(', ', array_keys($values));
$placeholders = implode(', ', array_fill(0, count($values), '?'));
$updateList = implode(', ', array_map(fn($c) => "$c = VALUES($c)", array_keys($values)));
$stmt = $db->prepare(
"INSERT INTO home_sections (slug, $columnList) VALUES (?, $placeholders)
ON DUPLICATE KEY UPDATE $updateList"
);
$stmt->execute(array_merge([$slug], array_values($values)));
Http::send(['ok' => true]);
}
}

View file

@ -48,6 +48,11 @@ class SettingsController
'permission_groups' => ['id', 'name', 'description', 'created_at', 'updated_at'], 'permission_groups' => ['id', 'name', 'description', 'created_at', 'updated_at'],
'permission_group_permissions' => ['permission_group_id', 'permission'], 'permission_group_permissions' => ['permission_group_id', 'permission'],
'legal_pages' => ['id', 'slug', 'title', 'body_html', 'updated_at'], 'legal_pages' => ['id', 'slug', 'title', 'body_html', 'updated_at'],
'home_sections' => [
'id', 'slug', 'eyebrow_de', 'eyebrow_en', 'title_de', 'title_en',
'body_html_de', 'body_html_en', 'text_align',
'button_label_de', 'button_label_en', 'button_url', 'updated_at',
],
]; ];
// Separat von TABLE_COLUMNS gehalten (nicht Teil der normalen Export-/Import-Schleife): // Separat von TABLE_COLUMNS gehalten (nicht Teil der normalen Export-/Import-Schleife):
@ -72,6 +77,7 @@ class SettingsController
'settings' => ['app_settings'], 'settings' => ['app_settings'],
'permissions' => ['permission_groups', 'permission_group_permissions'], 'permissions' => ['permission_groups', 'permission_group_permissions'],
'legal' => ['legal_pages'], 'legal' => ['legal_pages'],
'home' => ['home_sections'],
]; ];
// Welche Tabellenspalte(n) pro Tabelle einen Bild-Pfad enthalten - dieselbe Zuordnung // Welche Tabellenspalte(n) pro Tabelle einen Bild-Pfad enthalten - dieselbe Zuordnung

View file

@ -80,6 +80,27 @@ class Schema
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB", ) ENGINE=InnoDB",
// Die wichtigsten Text-Abschnitte der Startseite (YouTube-Sektion, Handwerk/Beratung,
// Einblicke, "Mehr als Car-Hifi") als editierbare Bloecke statt hart im JSX codiert -
// zweisprachig wie faqs, da die Seite einen Sprachumschalter hat. Fehlt eine Zeile
// fuer einen Slug, liefert HomeSectionController denselben Text, der zuvor im
// i18n-Woerterbuch stand (siehe DEFAULTS dort).
'home_sections' => "CREATE TABLE home_sections (
id INT AUTO_INCREMENT PRIMARY KEY,
slug VARCHAR(50) NOT NULL UNIQUE,
eyebrow_de VARCHAR(150) NULL,
eyebrow_en VARCHAR(150) NULL,
title_de VARCHAR(255) NULL,
title_en VARCHAR(255) NULL,
body_html_de TEXT NULL,
body_html_en TEXT NULL,
text_align ENUM('left','center','right') NOT NULL DEFAULT 'center',
button_label_de VARCHAR(100) NULL,
button_label_en VARCHAR(100) NULL,
button_url VARCHAR(500) NULL,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB",
'services' => "CREATE TABLE services ( 'services' => "CREATE TABLE services (
id INT AUTO_INCREMENT PRIMARY KEY, id INT AUTO_INCREMENT PRIMARY KEY,
icon_name VARCHAR(100) NOT NULL, icon_name VARCHAR(100) NOT NULL,
@ -344,6 +365,21 @@ class Schema
'body_html' => 'TEXT NOT NULL', 'body_html' => 'TEXT NOT NULL',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', 'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
], ],
'home_sections' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'slug' => 'VARCHAR(50) NOT NULL',
'eyebrow_de' => 'VARCHAR(150) NULL',
'eyebrow_en' => 'VARCHAR(150) NULL',
'title_de' => 'VARCHAR(255) NULL',
'title_en' => 'VARCHAR(255) NULL',
'body_html_de' => 'TEXT NULL',
'body_html_en' => 'TEXT NULL',
'text_align' => "ENUM('left','center','right') NOT NULL DEFAULT 'center'",
'button_label_de' => 'VARCHAR(100) NULL',
'button_label_en' => 'VARCHAR(100) NULL',
'button_url' => 'VARCHAR(500) NULL',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
],
'services' => [ 'services' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY', 'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'icon_name' => 'VARCHAR(100) NOT NULL', 'icon_name' => 'VARCHAR(100) NOT NULL',

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -43,9 +43,9 @@
"sameAs": ["https://www.youtube.com/@hifiplanet2812"] "sameAs": ["https://www.youtube.com/@hifiplanet2812"]
} }
</script> </script>
<script type="module" crossorigin src="/assets/index-DMjv3wnD.js"></script> <script type="module" crossorigin src="/assets/index-CbPgqJea.js"></script>
<link rel="modulepreload" crossorigin href="/assets/lucide-icons-Cg2IxtAO.js"> <link rel="modulepreload" crossorigin href="/assets/lucide-icons-Cg2IxtAO.js">
<link rel="stylesheet" crossorigin href="/assets/index-DHi-eHhm.css"> <link rel="stylesheet" crossorigin href="/assets/index-XtLTH0HQ.css">
</head> </head>
<body class="bg-white text-slate-900 dark:bg-slate-950 dark:text-slate-100"> <body class="bg-white text-slate-900 dark:bg-slate-950 dark:text-slate-100">
<div id="root"></div> <div id="root"></div>