import { CATEGORY_LANDING_DOCUMENTS, type CategoryLandingDocument } from './categoryLandingDocument' export interface CategoryLandingFaq { question: string answer: string } export interface CategoryLandingContent { eyebrow: string tagline: string intro: string article: CategoryLandingDocument['article'] faqs: readonly CategoryLandingFaq[] } const CATEGORY_EYEBROWS: Record = { 'arts-culture': 'رویدادهای هنر و فرهنگ', 'learning-experience': 'رویدادهای یادگیری و تجربه', 'games-entertainment': 'رویدادهای بازی و سرگرمی', 'sports-adventure': 'رویدادهای ورزش و ماجراجویی', 'food-gatherings': 'رویدادهای خوراک و دورهمی', 'conversation-connection': 'رویدادهای گفت‌وگو و ارتباط', } const toLandingContent = (slug: keyof typeof CATEGORY_LANDING_DOCUMENTS, document: CategoryLandingDocument): CategoryLandingContent => { const [tagline = '', ...introLines] = document.intro.split('\n') return { eyebrow: CATEGORY_EYEBROWS[slug], tagline, intro: introLines.join('\n').trim(), article: document.article, faqs: document.faqs, } } /** * Server-rendered, static editorial copy keyed by the backend category slug. * The generated document source is a lossless transcription of the supplied * DOCX; category name, image and metadata still come from the backend. */ export const CATEGORY_LANDING_CONTENT: Record = Object.fromEntries( Object.entries(CATEGORY_LANDING_DOCUMENTS).map(([slug, document]) => [ slug, toLandingContent(slug as keyof typeof CATEGORY_LANDING_DOCUMENTS, document), ]) ) export const getCategoryLandingContent = (categorySlug: string): CategoryLandingContent | undefined => CATEGORY_LANDING_CONTENT[categorySlug]