import type { Locale } from "@/lib/locales";

export const blogSlugs = [
  "saas-real-estate-lead-management",
  "builders-crm-erp-one-place",
  "society-maintenance-billing-software",
  "real-estate-challenges-without-crm",
  "digital-follow-ups-sales-conversion",
  "small-teams-use-saas-early",
  "connect-leads-projects-bookings-reports",
  "multilingual-software-indian-businesses",
] as const;

export type BlogSlug = (typeof blogSlugs)[number];
export type BlogTone = "violet" | "blue" | "green" | "orange" | "rose" | "cyan";
export type BlogCategoryKey = "realEstate" | "builder" | "society" | "growth" | "saas" | "digital";

export type BlogSection = {
  heading: string;
  paragraphs: string[];
  bullets?: string[];
  highlight?: string;
};

export type BlogPost = {
  slug: BlogSlug;
  title: string;
  excerpt: string;
  category: string;
  author: string;
  date: string;
  dateLabel: string;
  readTime: string;
  tone: BlogTone;
  visualLabel: string;
  seoTitle: string;
  seoDescription: string;
  sections: BlogSection[];
};

export type BlogPageCopy = {
  eyebrow: string;
  title: string;
  description: string;
  featured: string;
  latestTitle: string;
  latestDescription: string;
  searchPlaceholder: string;
  all: string;
  readMore: string;
  newsletterTitle: string;
  newsletterDescription: string;
  emailPlaceholder: string;
  invalidEmail: string;
  subscribe: string;
  newsletterReady: string;
  relatedTitle: string;
  backToBlogs: string;
  articleCtaTitle: string;
  articleCtaDescription: string;
  exploreProducts: string;
  ctaTitle: string;
  ctaDescription: string;
};

type ArticleTranslation = {
  title: string;
  excerpt: string;
  takeaways: string[];
  highlight: string;
};

const posts: Record<BlogSlug, { category: BlogCategoryKey; date: string; minutes: number; tone: BlogTone }> = {
  "saas-real-estate-lead-management": { category: "realEstate", date: "2026-05-22", minutes: 5, tone: "violet" },
  "builders-crm-erp-one-place": { category: "builder", date: "2026-05-15", minutes: 6, tone: "blue" },
  "society-maintenance-billing-software": { category: "society", date: "2026-05-08", minutes: 5, tone: "green" },
  "real-estate-challenges-without-crm": { category: "realEstate", date: "2026-04-30", minutes: 6, tone: "rose" },
  "digital-follow-ups-sales-conversion": { category: "growth", date: "2026-04-21", minutes: 4, tone: "orange" },
  "small-teams-use-saas-early": { category: "saas", date: "2026-04-12", minutes: 5, tone: "cyan" },
  "connect-leads-projects-bookings-reports": { category: "digital", date: "2026-04-04", minutes: 6, tone: "violet" },
  "multilingual-software-indian-businesses": { category: "saas", date: "2026-03-25", minutes: 4, tone: "green" },
};

const categoryLabels: Record<Locale, Record<BlogCategoryKey, string>> = {
  en: { realEstate: "Real Estate CRM", builder: "Builder Management", society: "Society Management", growth: "Business Growth", saas: "SaaS Tips", digital: "Digital Transformation" },
  hi: { realEstate: "रियल एस्टेट CRM", builder: "बिल्डर मैनेजमेंट", society: "सोसायटी मैनेजमेंट", growth: "बिजनेस ग्रोथ", saas: "SaaS टिप्स", digital: "डिजिटल ट्रांसफॉर्मेशन" },
  gu: { realEstate: "રિયલ એસ્ટેટ CRM", builder: "બિલ્ડર મેનેજમેન્ટ", society: "સોસાયટી મેનેજમેન્ટ", growth: "બિઝનેસ ગ્રોથ", saas: "SaaS ટિપ્સ", digital: "ડિજિટલ ટ્રાન્સફોર્મેશન" },
};

const pageCopy: Record<Locale, BlogPageCopy> = {
  en: {
    eyebrow: "PureSaaS Blogs",
    title: "Insights to grow smarter with SaaS, real estate, and digital operations.",
    description: "Read practical guides, product insights, business tips, and digital transformation ideas for real estate, builders, and societies.",
    featured: "Featured insight",
    latestTitle: "Latest business insights",
    latestDescription: "Simple ideas you can use to improve daily work, customer response, and business visibility.",
    searchPlaceholder: "Search articles",
    all: "All",
    readMore: "Read More",
    newsletterTitle: "Get practical SaaS and business growth insights.",
    newsletterDescription: "Useful ideas for better operations, delivered without unnecessary noise.",
    emailPlaceholder: "Your work email",
    invalidEmail: "Please enter a valid email address.",
    subscribe: "Subscribe",
    newsletterReady: "Newsletter delivery is being prepared. Please email hello@puresaas.in to join the early list.",
    relatedTitle: "Related insights",
    backToBlogs: "Back to Blogs",
    articleCtaTitle: "Want to turn these ideas into a clearer workflow?",
    articleCtaDescription: "See how PureSaaS can connect the work your team handles every day.",
    exploreProducts: "Explore Products",
    ctaTitle: "Want to see PureSaaS in action?",
    ctaDescription: "Book a focused demo and discover the right product workflow for your team.",
  },
  hi: {
    eyebrow: "PureSaaS ब्लॉग्स",
    title: "SaaS, रियल एस्टेट और डिजिटल कामकाज के साथ बेहतर ग्रोथ की जानकारी।",
    description: "रियल एस्टेट, बिल्डर्स और सोसायटी के लिए उपयोगी गाइड, प्रोडक्ट जानकारी और आसान बिजनेस टिप्स पढ़ें।",
    featured: "खास जानकारी",
    latestTitle: "नई बिजनेस जानकारी",
    latestDescription: "रोज़ का काम, ग्राहक को जवाब और बिजनेस की स्थिति बेहतर करने के आसान विचार।",
    searchPlaceholder: "आर्टिकल खोजें",
    all: "सभी",
    readMore: "और पढ़ें",
    newsletterTitle: "उपयोगी SaaS और बिजनेस ग्रोथ जानकारी पाएं।",
    newsletterDescription: "बेहतर कामकाज के लिए साफ और काम की जानकारी।",
    emailPlaceholder: "आपका वर्क ईमेल",
    invalidEmail: "कृपया सही ईमेल पता दर्ज करें।",
    subscribe: "सब्सक्राइब करें",
    newsletterReady: "न्यूज़लेटर तैयार किया जा रहा है। शुरुआती सूची में जुड़ने के लिए hello@puresaas.in पर ईमेल करें।",
    relatedTitle: "संबंधित आर्टिकल",
    backToBlogs: "ब्लॉग्स पर वापस जाएं",
    articleCtaTitle: "इन विचारों को साफ वर्कफ्लो में बदलना चाहते हैं?",
    articleCtaDescription: "देखें PureSaaS आपकी टीम के रोज़ के काम को कैसे जोड़ सकता है।",
    exploreProducts: "प्रोडक्ट्स देखें",
    ctaTitle: "PureSaaS को काम करते देखना चाहते हैं?",
    ctaDescription: "फोकस्ड डेमो बुक करें और अपनी टीम के लिए सही प्रोडक्ट वर्कफ्लो देखें।",
  },
  gu: {
    eyebrow: "PureSaaS બ્લોગ્સ",
    title: "SaaS, રિયલ એસ્ટેટ અને ડિજિટલ કામગીરી સાથે વધુ સારી ગ્રોથ માટે ઇન્સાઇટ્સ.",
    description: "રિયલ એસ્ટેટ, બિલ્ડર્સ અને સોસાયટી માટે ઉપયોગી ગાઇડ, પ્રોડક્ટ ઇન્સાઇટ્સ અને સરળ બિઝનેસ ટિપ્સ વાંચો.",
    featured: "ખાસ ઇન્સાઇટ",
    latestTitle: "નવી બિઝનેસ ઇન્સાઇટ્સ",
    latestDescription: "રોજનું કામ, ગ્રાહક પ્રતિસાદ અને બિઝનેસ વિઝિબિલિટી સુધારવા માટે સરળ વિચારો.",
    searchPlaceholder: "આર્ટિકલ શોધો",
    all: "બધા",
    readMore: "વધુ વાંચો",
    newsletterTitle: "ઉપયોગી SaaS અને બિઝનેસ ગ્રોથ ઇન્સાઇટ્સ મેળવો.",
    newsletterDescription: "સારી કામગીરી માટે સ્પષ્ટ અને ઉપયોગી વિચારો.",
    emailPlaceholder: "તમારો વર્ક ઇમેઇલ",
    invalidEmail: "કૃપા કરીને માન્ય ઇમેઇલ સરનામું દાખલ કરો.",
    subscribe: "સબ્સ્ક્રાઇબ કરો",
    newsletterReady: "ન્યૂઝલેટર તૈયાર થઈ રહ્યું છે. શરૂઆતની યાદીમાં જોડાવા hello@puresaas.in પર ઇમેઇલ કરો.",
    relatedTitle: "સંબંધિત આર્ટિકલ",
    backToBlogs: "બ્લોગ્સ પર પાછા જાઓ",
    articleCtaTitle: "આ વિચારોને સ્પષ્ટ વર્કફ્લોમાં બદલવા માંગો છો?",
    articleCtaDescription: "જુઓ PureSaaS તમારી ટીમના રોજના કામને કેવી રીતે જોડી શકે છે.",
    exploreProducts: "પ્રોડક્ટ્સ જુઓ",
    ctaTitle: "PureSaaS કામમાં જોવું છે?",
    ctaDescription: "ફોકસ્ડ ડેમો બુક કરો અને તમારી ટીમ માટે યોગ્ય પ્રોડક્ટ વર્કફ્લો જુઓ.",
  },
};

const articleCopy: Record<Locale, { contextHeading: string; contextBody: string; actionsHeading: string; actionsBody: string; resultsHeading: string; resultsBody: string }> = {
  en: {
    contextHeading: "Why this matters now",
    contextBody: "When a business grows, small gaps in visibility turn into missed follow-ups, delayed decisions, and repeated work. A connected workflow keeps the team focused on the next useful action.",
    actionsHeading: "What to improve first",
    actionsBody: "Start with the work your team repeats every day. Make ownership clear, keep status visible, and review a small set of meaningful reports regularly.",
    resultsHeading: "The business outcome",
    resultsBody: "The goal is not more software. The goal is a simpler operating rhythm: faster response, fewer missed tasks, clearer decisions, and a better customer experience.",
  },
  hi: {
    contextHeading: "यह अभी क्यों जरूरी है",
    contextBody: "बिजनेस बढ़ने पर छोटी कमियां छूटे हुए फॉलो-अप, देर से फैसले और दोहराए काम में बदल जाती हैं। जुड़ा हुआ वर्कफ्लो टीम को अगले जरूरी काम पर फोकस देता है।",
    actionsHeading: "पहले क्या बेहतर करें",
    actionsBody: "टीम के रोज़ दोहराए जाने वाले काम से शुरू करें। जिम्मेदारी साफ रखें, स्टेटस दिखाई दे और जरूरी रिपोर्ट नियमित देखें।",
    resultsHeading: "बिजनेस परिणाम",
    resultsBody: "लक्ष्य अधिक सॉफ्टवेयर नहीं है। लक्ष्य है आसान कामकाज: तेज जवाब, कम छूटे काम, साफ फैसले और बेहतर ग्राहक अनुभव।",
  },
  gu: {
    contextHeading: "આ હમણાં કેમ જરૂરી છે",
    contextBody: "બિઝનેસ વધે ત્યારે નાની ખામીઓ છૂટી ગયેલા ફોલો-અપ, મોડા નિર્ણય અને વારંવારના કામમાં બદલાય છે. જોડાયેલ વર્કફ્લો ટીમને આગળના ઉપયોગી કામ પર ફોકસ આપે છે.",
    actionsHeading: "પહેલા શું સુધારવું",
    actionsBody: "ટીમ રોજ જે કામ કરે છે ત્યાંથી શરૂ કરો. જવાબદારી સ્પષ્ટ રાખો, સ્ટેટસ દેખાય અને જરૂરી રિપોર્ટ નિયમિત જુઓ.",
    resultsHeading: "બિઝનેસ પરિણામ",
    resultsBody: "હેતુ વધુ સોફ્ટવેર નથી. હેતુ સરળ કામગીરી છે: ઝડપી પ્રતિસાદ, ઓછા છૂટેલા ટાસ્ક, સ્પષ્ટ નિર્ણય અને સારો ગ્રાહક અનુભવ.",
  },
};

const translations: Record<Locale, Record<BlogSlug, ArticleTranslation>> = {
  en: {
    "saas-real-estate-lead-management": { title: "How SaaS helps real estate teams manage leads and close faster", excerpt: "Learn how a connected CRM system improves lead tracking, follow-ups, team visibility, and sales growth.", takeaways: ["Capture every enquiry in one place", "Assign clear follow-up ownership", "Review pipeline movement with live reports"], highlight: "A lead is more valuable when the next action is always visible." },
    "builders-crm-erp-one-place": { title: "Why builders need a CRM and ERP system in one place", excerpt: "See why project sales, bookings, buyers, tasks, and construction updates work better when teams share one system.", takeaways: ["Connect sales and project information", "Track buyers and bookings clearly", "Reduce delays caused by scattered updates"], highlight: "Builders need one shared view from first enquiry to project progress." },
    "society-maintenance-billing-software": { title: "How housing societies can simplify maintenance and billing", excerpt: "A practical guide to clearer collections, resident communication, complaints, and everyday society operations.", takeaways: ["Keep bills and pending amounts visible", "Give complaints a clear status", "Share notices from one reliable place"], highlight: "Transparency makes society operations easier for committees and residents." },
    "real-estate-challenges-without-crm": { title: "Top challenges real estate businesses face without CRM", excerpt: "Understand the everyday sales problems that appear when enquiries, visits, and follow-ups stay disconnected.", takeaways: ["Find where enquiries are getting lost", "Replace memory-based follow-ups", "Give managers a clear sales view"], highlight: "When CRM is missing, teams often work hard without seeing where deals slow down." },
    "digital-follow-ups-sales-conversion": { title: "How digital follow-ups improve sales conversion", excerpt: "Simple follow-up discipline can help sales teams respond faster, stay consistent, and close more opportunities.", takeaways: ["Set a clear next action for each lead", "Use reminders instead of memory", "Review stale opportunities every week"], highlight: "Consistent follow-up is one of the simplest ways to improve conversion." },
    "small-teams-use-saas-early": { title: "Why small teams should use SaaS tools early", excerpt: "Starting with simple systems early prevents confusion and gives growing teams a stronger operating foundation.", takeaways: ["Create a repeatable workflow early", "Keep important records in one place", "Choose tools that can grow with the team"], highlight: "Small teams gain an advantage when clarity becomes a habit before growth accelerates." },
    "connect-leads-projects-bookings-reports": { title: "How PureSaaS connects leads, projects, bookings, and reports", excerpt: "Explore how connected information helps teams reduce repeated work and make faster business decisions.", takeaways: ["Link customer activity to business outcomes", "Reduce repeated data entry", "Use reports built from current information"], highlight: "Connected operations turn scattered updates into useful business visibility." },
    "multilingual-software-indian-businesses": { title: "Benefits of multilingual software for Indian businesses", excerpt: "Language-friendly software helps more team members understand workflows and use digital tools with confidence.", takeaways: ["Reduce hesitation for daily users", "Make onboarding more approachable", "Help teams adopt the same process consistently"], highlight: "Software creates more value when the people doing the work can understand it easily." },
  },
  hi: {
    "saas-real-estate-lead-management": { title: "SaaS से रियल एस्टेट टीम लीड कैसे संभाले और जल्दी डील बंद करे", excerpt: "जानें जुड़ा हुआ CRM लीड ट्रैकिंग, फॉलो-अप, टीम विज़िबिलिटी और सेल्स ग्रोथ कैसे बेहतर करता है।", takeaways: ["हर पूछताछ एक जगह रखें", "फॉलो-अप की जिम्मेदारी साफ रखें", "लाइव रिपोर्ट से पाइपलाइन देखें"], highlight: "लीड तब अधिक उपयोगी होती है जब अगला कदम हमेशा साफ दिखाई दे।" },
    "builders-crm-erp-one-place": { title: "बिल्डर्स को CRM और ERP एक ही जगह क्यों चाहिए", excerpt: "प्रोजेक्ट सेल्स, बुकिंग, खरीदार, टास्क और कंस्ट्रक्शन अपडेट एक सिस्टम में बेहतर काम करते हैं।", takeaways: ["सेल्स और प्रोजेक्ट जानकारी जोड़ें", "खरीदार और बुकिंग साफ ट्रैक करें", "बिखरे अपडेट से होने वाली देरी कम करें"], highlight: "बिल्डर्स को पहली पूछताछ से प्रोजेक्ट प्रगति तक एक साझा तस्वीर चाहिए।" },
    "society-maintenance-billing-software": { title: "हाउसिंग सोसायटी में मेंटेनेंस और बिलिंग कैसे आसान बनाएं", excerpt: "कलेक्शन, निवासी कम्युनिकेशन, शिकायत और रोज़ के सोसायटी काम के लिए उपयोगी गाइड।", takeaways: ["बिल और बकाया साफ रखें", "शिकायत का स्टेटस दिखाएं", "एक भरोसेमंद जगह से नोटिस शेयर करें"], highlight: "पारदर्शिता से कमेटी और निवासी दोनों के लिए काम आसान होता है।" },
    "real-estate-challenges-without-crm": { title: "CRM के बिना रियल एस्टेट बिजनेस की मुख्य समस्याएं", excerpt: "जब पूछताछ, विज़िट और फॉलो-अप जुड़े नहीं होते तब रोज़ की सेल्स समस्या कैसे बढ़ती है।", takeaways: ["छूटती पूछताछ पहचानें", "याददाश्त पर चलने वाला फॉलो-अप बदलें", "मैनेजर को साफ सेल्स तस्वीर दें"], highlight: "CRM न होने पर टीम मेहनत करती है, लेकिन डील कहां धीमी है यह साफ नहीं दिखता।" },
    "digital-follow-ups-sales-conversion": { title: "डिजिटल फॉलो-अप से सेल्स कन्वर्ज़न कैसे बेहतर होता है", excerpt: "आसान फॉलो-अप प्रक्रिया से टीम जल्दी जवाब देती है और अधिक अवसर बंद करती है।", takeaways: ["हर लीड का अगला कदम तय करें", "याद रखने की जगह रिमाइंडर रखें", "पुरानी लीड हर सप्ताह देखें"], highlight: "लगातार फॉलो-अप कन्वर्ज़न सुधारने का सबसे आसान तरीका है।" },
    "small-teams-use-saas-early": { title: "छोटी टीम को SaaS टूल जल्दी क्यों अपनाने चाहिए", excerpt: "शुरुआत में आसान सिस्टम अपनाने से बढ़ती टीम को मजबूत कामकाज की नींव मिलती है।", takeaways: ["जल्दी दोहराई जा सकने वाली प्रक्रिया बनाएं", "जरूरी रिकॉर्ड एक जगह रखें", "टीम के साथ बढ़ने वाला टूल चुनें"], highlight: "ग्रोथ तेज होने से पहले साफ कामकाज की आदत छोटी टीम को फायदा देती है।" },
    "connect-leads-projects-bookings-reports": { title: "PureSaaS लीड, प्रोजेक्ट, बुकिंग और रिपोर्ट कैसे जोड़ता है", excerpt: "जुड़ी जानकारी से टीम दोहराया काम कम करके जल्दी बिजनेस फैसला ले सकती है।", takeaways: ["ग्राहक गतिविधि को परिणाम से जोड़ें", "बार-बार डेटा डालना कम करें", "मौजूदा जानकारी से रिपोर्ट देखें"], highlight: "जुड़ा हुआ काम बिखरे अपडेट को उपयोगी बिजनेस विज़िबिलिटी में बदलता है।" },
    "multilingual-software-indian-businesses": { title: "भारतीय बिजनेस के लिए मल्टी-लैंग्वेज सॉफ्टवेयर के फायदे", excerpt: "भाषा के अनुसार आसान सॉफ्टवेयर टीम को वर्कफ्लो समझने और भरोसे से उपयोग करने में मदद करता है।", takeaways: ["रोज़ के उपयोगकर्ता की झिझक कम करें", "ऑनबोर्डिंग आसान बनाएं", "एक जैसी प्रक्रिया अपनाने में मदद करें"], highlight: "सॉफ्टवेयर तब अधिक उपयोगी है जब काम करने वाले लोग उसे आसानी से समझ सकें।" },
  },
  gu: {
    "saas-real-estate-lead-management": { title: "SaaSથી રિયલ એસ્ટેટ ટીમ લીડ કેવી રીતે સંભાળે અને ઝડપથી ડીલ બંધ કરે", excerpt: "જાણો જોડાયેલ CRM લીડ ટ્રેકિંગ, ફોલો-અપ, ટીમ વિઝિબિલિટી અને સેલ્સ ગ્રોથ કેવી રીતે સુધારે છે.", takeaways: ["દરેક પૂછપરછ એક જગ્યાએ રાખો", "ફોલો-અપની જવાબદારી સ્પષ્ટ રાખો", "લાઇવ રિપોર્ટથી પાઇપલાઇન જુઓ"], highlight: "લીડ ત્યારે વધુ ઉપયોગી બને છે જ્યારે આગળનું પગલું હંમેશા દેખાય." },
    "builders-crm-erp-one-place": { title: "બિલ્ડર્સને CRM અને ERP એક જ જગ્યાએ કેમ જોઈએ", excerpt: "પ્રોજેક્ટ સેલ્સ, બુકિંગ, ખરીદદાર, ટાસ્ક અને કન્સ્ટ્રક્શન અપડેટ એક સિસ્ટમમાં વધુ સારી રીતે કામ કરે છે.", takeaways: ["સેલ્સ અને પ્રોજેક્ટ માહિતી જોડો", "ખરીદદાર અને બુકિંગ સ્પષ્ટ ટ્રેક કરો", "છૂટા અપડેટથી થતો વિલંબ ઘટાડો"], highlight: "બિલ્ડર્સને પહેલી પૂછપરછથી પ્રોજેક્ટ પ્રગતિ સુધી એક શેર કરેલું દૃશ્ય જોઈએ." },
    "society-maintenance-billing-software": { title: "હાઉસિંગ સોસાયટીમાં મેન્ટેનન્સ અને બિલિંગ કેવી રીતે સરળ બનાવવું", excerpt: "કલેક્શન, રહેવાસી કમ્યુનિકેશન, ફરિયાદ અને રોજની સોસાયટી કામગીરી માટે ઉપયોગી ગાઇડ.", takeaways: ["બિલ અને બાકી રકમ સ્પષ્ટ રાખો", "ફરિયાદનો સ્ટેટસ બતાવો", "એક વિશ્વસનીય જગ્યાથી નોટિસ શેર કરો"], highlight: "પારદર્શિતાથી કમિટી અને રહેવાસી બંને માટે કામગીરી સરળ બને છે." },
    "real-estate-challenges-without-crm": { title: "CRM વગર રિયલ એસ્ટેટ બિઝનેસની મુખ્ય સમસ્યાઓ", excerpt: "પૂછપરછ, વિઝિટ અને ફોલો-અપ જોડાયેલા ન હોય ત્યારે રોજની સેલ્સ સમસ્યાઓ કેવી રીતે વધે છે.", takeaways: ["છૂટી જતી પૂછપરછ ઓળખો", "યાદદાસ્ત આધારિત ફોલો-અપ બદલો", "મેનેજરને સ્પષ્ટ સેલ્સ દૃશ્ય આપો"], highlight: "CRM વગર ટીમ મહેનત કરે છે, પણ ડીલ ક્યાં ધીમી પડે છે તે સ્પષ્ટ દેખાતું નથી." },
    "digital-follow-ups-sales-conversion": { title: "ડિજિટલ ફોલો-અપથી સેલ્સ કન્વર્ઝન કેવી રીતે સુધરે છે", excerpt: "સરળ ફોલો-અપ પ્રક્રિયાથી ટીમ ઝડપથી જવાબ આપે છે અને વધુ તક બંધ કરે છે.", takeaways: ["દરેક લીડ માટે આગળનું પગલું નક્કી કરો", "યાદ રાખવાને બદલે રિમાઇન્ડર વાપરો", "જૂની તક દર અઠવાડિયે જુઓ"], highlight: "સતત ફોલો-અપ કન્વર્ઝન સુધારવાનો સૌથી સરળ રસ્તો છે." },
    "small-teams-use-saas-early": { title: "નાની ટીમે SaaS ટૂલ વહેલા કેમ અપનાવવા જોઈએ", excerpt: "શરૂઆતમાં સરળ સિસ્ટમ અપનાવવાથી વધતી ટીમને મજબૂત કામગીરીનો આધાર મળે છે.", takeaways: ["વહેલી તકે ફરી વાપરી શકાય તેવી પ્રક્રિયા બનાવો", "જરૂરી રેકોર્ડ એક જગ્યાએ રાખો", "ટીમ સાથે વધે તેવું ટૂલ પસંદ કરો"], highlight: "ગ્રોથ ઝડપી થાય તે પહેલાં સ્પષ્ટ કામગીરીની ટેવ નાની ટીમને ફાયદો આપે છે." },
    "connect-leads-projects-bookings-reports": { title: "PureSaaS લીડ, પ્રોજેક્ટ, બુકિંગ અને રિપોર્ટ કેવી રીતે જોડે છે", excerpt: "જોડાયેલી માહિતીથી ટીમ વારંવારનું કામ ઘટાડીને ઝડપથી બિઝનેસ નિર્ણય લઈ શકે છે.", takeaways: ["ગ્રાહક પ્રવૃત્તિને પરિણામ સાથે જોડો", "વારંવાર ડેટા એન્ટ્રી ઘટાડો", "હાલની માહિતીથી રિપોર્ટ જુઓ"], highlight: "જોડાયેલી કામગીરી છૂટા અપડેટને ઉપયોગી બિઝનેસ વિઝિબિલિટીમાં બદલે છે." },
    "multilingual-software-indian-businesses": { title: "ભારતીય બિઝનેસ માટે મલ્ટી-લેંગ્વેજ સોફ્ટવેરના લાભ", excerpt: "ભાષા પ્રમાણે સરળ સોફ્ટવેર ટીમને વર્કફ્લો સમજવા અને વિશ્વાસથી વાપરવામાં મદદ કરે છે.", takeaways: ["રોજના ઉપયોગકર્તાની અચકાટ ઘટાડો", "ઓનબોર્ડિંગ સરળ બનાવો", "એક જેવી પ્રક્રિયા અપનાવવામાં મદદ કરો"], highlight: "સોફ્ટવેર ત્યારે વધુ ઉપયોગી બને છે જ્યારે કામ કરતા લોકો તેને સરળતાથી સમજી શકે." },
  },
};

export function getBlogPageCopy(locale: Locale) {
  return pageCopy[locale];
}

export function getBlogs(locale: Locale): BlogPost[] {
  const copy = articleCopy[locale];
  return blogSlugs.map((slug) => {
    const post = posts[slug];
    const translation = translations[locale][slug];
    const category = categoryLabels[locale][post.category];
    return {
      slug,
      title: translation.title,
      excerpt: translation.excerpt,
      category,
      author: "PureSaaS Team",
      date: post.date,
      dateLabel: formatBlogDate(locale, post.date),
      readTime: `${post.minutes} min read`,
      tone: post.tone,
      visualLabel: category,
      seoTitle: translation.title,
      seoDescription: translation.excerpt,
      sections: [
        { heading: copy.contextHeading, paragraphs: [translation.excerpt, copy.contextBody] },
        { heading: copy.actionsHeading, paragraphs: [copy.actionsBody], bullets: translation.takeaways },
        { heading: copy.resultsHeading, paragraphs: [copy.resultsBody], highlight: translation.highlight },
      ],
    };
  });
}

export function getBlog(locale: Locale, slug: string) {
  return getBlogs(locale).find((post) => post.slug === slug);
}

export function getRelatedBlogs(locale: Locale, slug: BlogSlug, limit = 3) {
  const allPosts = getBlogs(locale);
  const current = allPosts.find((post) => post.slug === slug);
  return allPosts
    .filter((post) => post.slug !== slug)
    .sort((a, b) => Number(b.category === current?.category) - Number(a.category === current?.category))
    .slice(0, limit);
}

export function getBlogCategories(locale: Locale) {
  return Object.values(categoryLabels[locale]);
}

function formatBlogDate(locale: Locale, date: string) {
  return new Intl.DateTimeFormat(locale === "en" ? "en-IN" : locale === "hi" ? "hi-IN" : "gu-IN", {
    day: "numeric",
    month: "short",
    year: "numeric",
    timeZone: "UTC",
  }).format(new Date(`${date}T00:00:00Z`));
}
