<?php

use App\Http\Controllers\Api\V1\PublicSite\SitemapController;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    $index = public_path('index.html');

    abort_unless(file_exists($index), 404);

    return response()->file($index);
});

/*
 * Crawler-facing files (§151). These live outside /api so they sit at the
 * conventional paths and need no JavaScript to read.
 */
Route::get('/sitemap.xml', [SitemapController::class, 'sitemap'])->name('sitemap');
Route::get('/robots.txt', [SitemapController::class, 'robots'])->name('robots');

Route::fallback(function () {
    $index = public_path('index.html');

    abort_unless(file_exists($index), 404);

    return response()->file($index);
});
