28 lines
895 B
PHP
28 lines
895 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\News;
|
|
use App\Services\SeoService;
|
|
use Illuminate\Http\Response;
|
|
|
|
class SeoController extends Controller
|
|
{
|
|
public function robots(SeoService $seo): Response
|
|
{
|
|
$rules = config('seo.indexable')
|
|
? "User-agent: *\nAllow: /\nDisallow: /api/\nDisallow: /launcher/\nDisallow: /appcast.xml\nDisallow: /up\n\nSitemap: ".$seo->routeUrl('seo.sitemap')."\n"
|
|
: "User-agent: *\nDisallow: /\n";
|
|
|
|
return response($rules, 200, ['Content-Type' => 'text/plain; charset=UTF-8']);
|
|
}
|
|
|
|
public function sitemap(SeoService $seo): Response
|
|
{
|
|
return response()->view('seo.sitemap', [
|
|
'seo' => $seo,
|
|
'articles' => News::query()->published()->select(['id', 'updated_at'])->orderBy('id')->cursor(),
|
|
], 200, ['Content-Type' => 'application/xml; charset=UTF-8']);
|
|
}
|
|
}
|