import {slugifyTitre} from './stageHref';

/**
 * URL d'une fiche ville : /{locale}/ville/{id}/{nom-encodé} (spec : /ville/13810/Rennes), servie par
 * la page /localisation/villes/{id} grâce à une réécriture Next. Sans nom connu, l'URL reste valable.
 */
export function villeHref(locale: string, vilId: number | string, nom?: string | null): string {
  const base = `/${locale}/ville/${vilId}`;
  return nom?.trim() ? `${base}/${slugifyTitre(nom)}` : base;
}
