<?php

namespace App\Controllers;

use App\Services\Seo\SitemapService;

class SeoController extends BaseController
{
    public function sitemap()
    {
        $xml = (new SitemapService())->generate();
        return $this->response->setContentType('application/xml')->setBody($xml);
    }

    public function robots()
    {
        $lines = [
            'User-agent: *',
            'Allow: /',
            'Disallow: /admin/',
            'Disallow: /api/',
            'Disallow: /install/',
            '',
            'Sitemap: ' . base_url('sitemap.xml'),
        ];

        return $this->response->setContentType('text/plain')->setBody(implode("\n", $lines));
    }
}
