diff --git a/app/Http/Controllers/GameController.php b/app/Http/Controllers/GameController.php index 6e60866..cac3d37 100644 --- a/app/Http/Controllers/GameController.php +++ b/app/Http/Controllers/GameController.php @@ -39,7 +39,10 @@ class GameController extends Controller $genres = Genre::orderBy('name')->get(); $platforms = Platform::orderBy('name')->get(); - return view('games.index', compact('games', 'genres', 'platforms')); + $shouldNoindex = ($request->get('page', 1) > 1) || + (collect(['genre', 'platform', 'year', 'sort', 'q'])->filter(fn($k) => $request->filled($k))->count() >= 2); + + return view('games.index', compact('games', 'genres', 'platforms', 'shouldNoindex')); } public function show(Game $game) @@ -61,7 +64,18 @@ class GameController extends Controller ->limit(20) ->get(); - $response = view('games.show', compact('game', 'userGame', 'userReview', 'userLists', 'comments')); + $similarGames = collect(); + if ($game->genres->isNotEmpty()) { + $similarGames = Game::published() + ->whereHas('genres', fn($q) => $q->whereIn('genres.id', $game->genres->pluck('id'))) + ->where('id', '!=', $game->id) + ->where('rating_count', '>=', 1) + ->orderByDesc('rating_avg') + ->limit(6) + ->get(); + } + + $response = view('games.show', compact('game', 'userGame', 'userReview', 'userLists', 'comments', 'similarGames')); return auth()->check() ? $response : response($response)->header('Cache-Control', 'public, max-age=300'); diff --git a/public/robots.txt b/public/robots.txt index 12aa2e9..56c794e 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,6 +1,18 @@ User-agent: * Allow: / -Disallow: /profile + Disallow: /dashboard +Disallow: /profile +Disallow: /library +Disallow: /notifications +Disallow: /activity +Disallow: /login +Disallow: /register +Disallow: /forgot-password +Disallow: /reset-password +Disallow: /verify-email +Disallow: /games/search +Disallow: /lists +Disallow: /*?*page=* Sitemap: https://gamelog.ro/sitemap.xml diff --git a/resources/views/games/index.blade.php b/resources/views/games/index.blade.php index 0237f4d..94419d1 100644 --- a/resources/views/games/index.blade.php +++ b/resources/views/games/index.blade.php @@ -1,6 +1,11 @@ @extends('layouts.app') @section('title', 'Browse Games — LoreKeepers') +@section('description', 'Browse and discover video games. Filter by genre, platform, and year. Find your next favorite game on LoreKeepers.') +@section('canonical', route('games.index')) +@if($shouldNoindex ?? false) +@section('robots', 'noindex,follow') +@endif @section('content')