'use client'; import Link from 'next/link'; import { motion } from 'framer-motion'; import { useLocale } from '@/lib/i18n/locale-context'; import type { PostContent, Block } from '@/lib/content/posts'; import { cn } from '@/lib/utils'; const FA_DIGITS = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'] as const; const toFa = (s: string | number) => s.toString().replace(/\d/g, (d) => FA_DIGITS[Number(d)]); type Meta = { title: string; category: string; readTime: number }; const ACCENT_TEXT: Record = { electric: 'text-electric', violet: 'text-violet', magenta: 'text-magenta', emerald: 'text-emerald', cyan: 'text-cyan', }; const ACCENT_BORDER: Record = { electric: 'border-electric/30 bg-electric/5 text-electric', violet: 'border-violet/30 bg-violet/5 text-violet', magenta: 'border-magenta/30 bg-magenta/5 text-magenta', emerald: 'border-emerald/30 bg-emerald/5 text-emerald', cyan: 'border-cyan/30 bg-cyan/5 text-cyan', }; export function BlogArticle({ meta, content, }: { meta: { fa: Meta; en: Meta }; content: PostContent; }) { const { t, locale } = useLocale(); const m = meta[locale]; const body = content[locale]; const dir = locale === 'fa' ? 'rtl' : 'ltr'; const dateLabel = new Intl.DateTimeFormat( locale === 'fa' ? 'fa-IR' : 'en-US', { year: 'numeric', month: 'long', day: 'numeric' }, ).format(new Date(content.date)); return (
{/* Cover glow */}
{t.nav.blog}
{m.category} {dateLabel} {locale === 'fa' ? toFa(m.readTime) : m.readTime}{' '} {t.blog.readTimeSuffix}

{m.title}

{body.lead}

{/* Body */}
{body.blocks.map((block, i) => ( ))}
{/* CTA */}

{locale === 'fa' ? 'این موضوع به سیستم شما مربوط است؟ بیایید درباره‌اش صحبت کنیم.' : 'Is this relevant to your system? Let’s talk it through.'}

{t.hero.ctaPrimary} {t.nav.blog}
); } function BlockView({ block, accent, }: { block: Block; accent: PostContent['accent']; }) { switch (block.k) { case 'h2': return (

{block.t}

); case 'p': return (

{block.t}

); case 'ul': return ( ); case 'quote': return (
{block.t}
); case 'code': return (
          {block.t}
        
); } }