/** * Content Loader - Centralized content management * * This module provides type-safe access to all JSON content files. * Content can be easily modified by editing the JSON files without code changes. * * Usage: * import { content, getPageContent } from '@/content' * * // Access specific page content * const aboutContent = content.pages.about * * // Or use the helper function * const servicesContent = getPageContent('services') */ import type { SiteContent, CommonContent, HomePageContent, AboutPageContent, ServicesPageContent, ContactPageContent, LegalPageContent } from './types' import { validateContent } from './schema' // Import JSON files import commonJson from './common.json' import homeJson from './pages/home.json' import aboutJson from './pages/about.json' import servicesJson from './pages/services.json' import contactJson from './pages/contact.json' import adatvedelemJson from './pages/adatvedelem.json' import hasznalatiFeltetelekJson from './pages/hasznalati-feltetelek.json' function loadValidatedContent(fileKey: string, value: unknown): T { const result = validateContent(fileKey, value) if (!result.ok) { throw new Error(`Érvénytelen content JSON (${fileKey}): ${result.errors.join('; ')}`) } return value as T } // Runtime validation prevents malformed JSON from silently reaching the UI. const common = loadValidatedContent('common', commonJson) const home = loadValidatedContent('home', homeJson) const about = loadValidatedContent('about', aboutJson) const services = loadValidatedContent('services', servicesJson) const contact = loadValidatedContent('contact', contactJson) const adatvedelem = loadValidatedContent('adatvedelem', adatvedelemJson) const hasznalatiFeltetelek = loadValidatedContent('hasznalatiFeltetelek', hasznalatiFeltetelekJson) // Combined content object export const content: SiteContent = { common, pages: { home, about, services, contact, adatvedelem, hasznalatiFeltetelek } } // Helper function to get page content with type safety export function getPageContent( page: T ): SiteContent['pages'][T] { return content.pages[page] } // Export individual content for direct imports export { common, home, about, services, contact, adatvedelem, hasznalatiFeltetelek } // Re-export types export * from './types'