Files
gamelog/app/Console/Commands/GenerateSitemapCommand.php
T
MarkandClaude Sonnet 4.6 bb6323b141 Fix SEO audit issues: brand rename cleanup, sitemap HTTPS, structured data, titles, descriptions, canonicals
- Replace all "GameLog" brand references with "LoreKeepers" (og:site_name, twitter meta, top-rated, community lists)
- Force HTTPS in sitemap generation; update .env.example APP_URL to https://lorekeepers.games
- Enhance VideoGame JSON-LD on game pages: add image, datePublished, author fields
- Improve title tags across all main pages (keyword-rich, include year on game pages)
- Add/update meta descriptions and og:description on all public pages
- Add canonical tag and og_title/og_description to homepage
- Add rel=prev/next pagination links on /games via head_links stack
- Add @stack('head_links') to layout head for child view injection
- Smarter description truncation on game pages (last sentence boundary)
- Improve screenshot alt text with genre context

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-02 14:49:27 +03:00

57 lines
2.0 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Models\Game;
use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\URL;
use Spatie\Sitemap\Sitemap;
use Spatie\Sitemap\Tags\Url;
class GenerateSitemapCommand extends Command
{
protected $signature = 'sitemap:generate';
protected $description = 'Generate the sitemap.xml file';
public function handle(): int
{
URL::forceScheme('https');
$sitemap = Sitemap::create()
->add(Url::create('/')->setPriority(1.0)->setChangeFrequency(Url::CHANGE_FREQUENCY_DAILY))
->add(Url::create('/games')->setPriority(0.9)->setChangeFrequency(Url::CHANGE_FREQUENCY_DAILY))
->add(Url::create('/top-rated')->setPriority(0.8)->setChangeFrequency(Url::CHANGE_FREQUENCY_WEEKLY))
->add(Url::create('/new-releases')->setPriority(0.8)->setChangeFrequency(Url::CHANGE_FREQUENCY_DAILY));
Game::select('slug', 'updated_at')->chunk(500, function ($games) use ($sitemap) {
foreach ($games as $game) {
$sitemap->add(
Url::create("/games/{$game->slug}")
->setLastModificationDate($game->updated_at)
->setPriority(0.7)
->setChangeFrequency(Url::CHANGE_FREQUENCY_WEEKLY)
);
}
});
User::where('is_private', false)
->select('slug', 'updated_at')
->chunk(500, function ($users) use ($sitemap) {
foreach ($users as $user) {
$sitemap->add(
Url::create("/users/{$user->slug}")
->setLastModificationDate($user->updated_at)
->setPriority(0.5)
->setChangeFrequency(Url::CHANGE_FREQUENCY_WEEKLY)
);
}
});
$sitemap->writeToFile(public_path('sitemap.xml'));
$this->info('Sitemap generated at public/sitemap.xml');
return self::SUCCESS;
}
}