// Slug helpers for topic URLs.

const SPECIAL_CASES: Record<string, string> = {
  "gods word": "God's Word",
  "gods love": "God's Love",
  "gods grace": "God's Grace",
  "gods will": "God's Will",
  "gods presence": "God's Presence",
  "gods promises": "God's Promises",
  "jesus return": "Jesus' Return",
  "spiritual growth": "Spiritual Growth",
  "trust god": "Trust God",
  "seek god": "Seek God",
};

export function topicToSlug(topic: string): string {
  return topic
    .toLowerCase()
    .trim()
    .replace(/['']/g, "")
    .replace(/&/g, "and")
    .replace(/[^a-z0-9]+/g, "-")
    .replace(/^-+|-+$/g, "");
}

export function slugToTopic(slug: string): string {
  const normalized = decodeURIComponent(slug).replace(/-/g, " ").trim();
  const key = normalized.toLowerCase();
  if (SPECIAL_CASES[key]) return SPECIAL_CASES[key];
  return normalized.replace(/\b\w/g, (c) => c.toUpperCase());
}
