admin/lib/seo/categoryLandingContent.ts
alisaza e1eaf5eff5 feat: initial ghabilee-admin backoffice app
Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js
app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
2026-09-05 13:12:59 +03:30

51 lines
1.9 KiB
TypeScript

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<keyof typeof CATEGORY_LANDING_DOCUMENTS, string> = {
'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<string, CategoryLandingContent> = 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]