<?php

use App\Http\Controllers\ArticleController;
use App\Http\Controllers\ContactController;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\NewsletterController;
use App\Http\Controllers\SitemapController;
use Illuminate\Support\Facades\Route;

// Racine -> redirige vers la langue par défaut.
Route::redirect('/', '/'.config('app.locale', 'fr'));

Route::get('/sitemap.xml', SitemapController::class)->name('sitemap');

Route::middleware('setlocale')->prefix('{locale}')->where(['locale' => 'fr|en'])->group(function () {
    Route::get('/', [HomeController::class, 'index'])->name('home');
    Route::get('/actualites/{slug}', [ArticleController::class, 'show'])->name('articles.show');
    Route::post('/contact', [ContactController::class, 'store'])
        ->middleware('throttle:5,1')
        ->name('contact.store');
    Route::post('/newsletter', [NewsletterController::class, 'store'])
        ->middleware('throttle:5,1')
        ->name('newsletter.store');
});
