<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\CategoryController;
use App\Http\Controllers\AuthorController;
use App\Http\Controllers\SitemapController;
use App\Http\Controllers\SubscriberController;

Route::get('/robots.txt', function () {
    return response(file_get_contents(base_path('robots.txt')), 200)
        ->header('Content-Type', 'text/plain');
});

Route::get('/', [HomeController::class, 'index'])->name('index');
Route::get('/search', [HomeController::class, 'search'])->name('search');

Route::view('/about', 'about')->name('about');
Route::view('/privacy-policy', 'privacyPolicy')->name('privacyPolicy');

Route::get('/category/{slug}', [CategoryController::class, 'show'])->name('category.show');
Route::get('/author/{slug}',   [AuthorController::class, 'show'])->name('author.show');

Route::post('/subscribe', [SubscriberController::class, 'store'])->name('subscribe');

Route::get('/sitemap.xml',            [SitemapController::class, 'index']);
Route::get('/sitemap-news.xml',       [SitemapController::class, 'news']);
Route::get('/sitemap-articles.xml',   [SitemapController::class, 'articles']);
Route::get('/sitemap-pages.xml',      [SitemapController::class, 'pages']);
Route::get('/sitemap-categories.xml', [SitemapController::class, 'categories']);
Route::get('/sitemap-authors.xml',    [SitemapController::class, 'authors']);

// Article detail — must be LAST
Route::get('/{category}/{slug}', [HomeController::class, 'show'])->name('news.show');
