import type { NextConfig } from "next";
import path from "path";

/** Redirects 301 — doublon volontaire de LEGACY_SERVICE_REDIRECTS (évite d’importer src/ avec alias @/) */
const serviceRedirects = [
  ["entretien", "entretien-auto-auxerre"],
  ["vidange", "vidange-auxerre"],
  ["freinage", "freinage-auxerre"],
  ["distribution", "distribution-auxerre"],
  ["diagnostic", "diagnostic-auto-auxerre"],
  ["suspension", "suspension-amortisseurs-auxerre"],
  ["pneumatiques", "pneus-auxerre"],
  ["batterie", "batterie-auto-auxerre"],
  ["climatisation", "climatisation-auto-auxerre"],
  ["recherche-panne", "recherche-panne-auto-auxerre"],
  ["mecanique-generale", "mecanique-generale-auxerre"],
  ["revision-constructeur", "entretien-auto-auxerre"],
].map(([from, to]) => ({
  source: `/services/${from}`,
  destination: `/services/${to}`,
  permanent: true,
}));

const nextConfig: NextConfig = {
  images: {
    formats: ["image/avif", "image/webp"],
  },
  outputFileTracingRoot: path.join(__dirname),
  async redirects() {
    return serviceRedirects;
  },
};

export default nextConfig;
