seo
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?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']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user