<?php

namespace App\Http\Controllers;

use App\Models\BlogPost;
use Illuminate\Http\Response;

class RssFeedController extends Controller
{
    public function index(): Response
    {
        $posts = BlogPost::published()
            ->orderByDesc('published_at')
            ->limit(20)
            ->get(['slug', 'title', 'excerpt', 'content', 'cover_image', 'published_at', 'updated_at', 'category', 'author_id', 'meta_title', 'meta_description']);

        return response()
            ->view('rss', compact('posts'))
            ->header('Content-Type', 'application/rss+xml; charset=utf-8');
    }
}
