feat(controller): add HTMLSitemapController for generating HTML sitemap

- Added HTMLSitemapController to generate sitemap with cached data
- Updated footer.blade.php and index.blade.php for sitemap links
This commit is contained in:
Rico van Zelst
2024-03-03 17:23:22 +01:00
parent e69a1b1844
commit 37bc210923
4 changed files with 154 additions and 5 deletions

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Http\Controllers;
use App\Models\Champion;
use App\Models\ChampionSkin;
use App\Models\SummonerIcon;
use Illuminate\Support\Facades\Cache;
use Spatie\Sheets\Facades\Sheets;
class HTMLSitemapController extends Controller
{
public function index()
{
$twentyHoursInSeconds = 60 * 60 * 20;
$champions = Cache::remember('sitemap_championsCache', $twentyHoursInSeconds, fn () => Champion::orderBy('name')->get());
$skins = Cache::remember('sitemap_championSkinsCache', $twentyHoursInSeconds, fn () => ChampionSkin::orderBy('skin_name')->get());
$icons = Cache::remember('sitemap_iconsCache', $twentyHoursInSeconds, fn () => SummonerIcon::orderBy('title')->get());
$posts = Sheets::all()->sortByDesc('date');
return view('sitemap.index', compact('champions', 'skins', 'icons', 'posts'));
}
}

View File

@@ -30,12 +30,20 @@
</li> </li>
</ul> </ul>
<div class="flex items-center justify-center w-full mb-6"> <div class="flex items-center justify-center w-full mb-4">
<a href="https://www.producthunt.com/posts/heimerdinger-lol?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-heimerdinger&#0045;lol" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=442110&theme=dark" alt="Heimerdinger&#0046;lol - Discover&#0032;LoL&#0058;&#0032;Champions&#0044;&#0032;Skins&#0044;&#0032;Sales&#0032;and&#0032;More&#0033; | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a> <a href="https://www.producthunt.com/posts/heimerdinger-lol?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-heimerdinger&#0045;lol"
target="_blank"><img
src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=442110&theme=dark"
alt="Heimerdinger&#0046;lol - Discover&#0032;LoL&#0058;&#0032;Champions&#0044;&#0032;Skins&#0044;&#0032;Sales&#0032;and&#0032;More&#0033; | Product Hunt"
style="width: 250px; height: 54px;" width="250" height="54"/></a>
</div> </div>
<span
class="flex mb-2 flex-row items-center justify-center text-sm text-gray-300 whitespace-pre sm:text-center dark:text-gray-300"> <a
href="{{route('sitemap.index')}}" class="hover:underline">Sitemap</a></span>
<span <span
class="flex flex-row items-center justify-center text-sm text-gray-500 whitespace-pre sm:text-center dark:text-gray-400">© {{date('Y')}} <a class="flex flex-row items-center justify-center text-sm text-gray-500 whitespace-pre sm:text-center dark:text-gray-400">© {{date('Y')}} <a
href="/" class=" hover:underline">Heimerdinger.LoL</a> Made with <a aria-label="Find out more about the creator of Heimerdinger.lol" href="https://rico.sh"><x-iconsax-bul-heart-circle href="/" class=" hover:underline">Heimerdinger.LoL</a> Made with <a
aria-label="Find out more about the creator of Heimerdinger.lol" href="https://rico.sh"><x-iconsax-bul-heart-circle
class="relative self-center inline-block w-5 text-red-400"/></a></span> class="relative self-center inline-block w-5 text-red-400"/></a></span>
</div> </div>
</footer> </footer>

View File

@@ -0,0 +1,110 @@
@extends('layouts.app')
@section('title', 'Heimerdinger.LoL • Sitemap (HTML)')
@section('description', 'Discover the complete sitemap for Heimerdinger.LoL,
your go-to source for all things League of Legends.
Explore champions, skins, game assets, and more in one convenient location.')
@section('content')
<div class="flex justify-center"> <!-- Centering container -->
<div>
<h1 class="mt-6 mb-6 text-3xl font-bold text-center text-transparent uppercase sm:text-4xl bg-gradient-to-bl from-orange-300 to-orange-500 bg-clip-text">
Heimerdinger Sitemap</h1>
<div class="grid grid-cols-5 gap-4 ml-16 mr-16">
<div>
<h2 class="text-2xl font-bold text-stone-300">General</h2>
<ul class="mt-2">
<li class="mb-1">
<a href="{{ route('home') }}"
class="text-orange-400 hover:text-orange-500">Home</a>
</li>
<li class="mb-1">
<a href="{{ route('champions.index') }}"
class="text-orange-400 hover:text-orange-500">Champions</a>
</li>
<li class="mb-1">
<a href="{{ route('skins.index') }}"
class="text-orange-400 hover:text-orange-500">Skins</a>
</li>
<li class="mb-1">
<a href="{{ route('assets.icons.index') }}"
class="text-orange-400 hover:text-orange-500">Icons</a>
</li>
<li class="mb-1">
<a href="{{ route('assets.emotes.index') }}"
class="text-orange-400 hover:text-orange-500">Emotes</a>
</li>
<li class="mb-1">
<a href="{{ route('sales.index') }}"
class="text-orange-400 hover:text-orange-500">Sale Rotation</a>
</li>
<li class="mb-1">
<a href="{{ route('about.index') }}"
class="text-orange-400 hover:text-orange-500">About</a>
</li>
<li class="mb-1">
<a href="{{ route('about.faq.leagueoflegends') }}"
class="text-orange-400 hover:text-orange-500">FAQ: League of Legends</a>
</li>
<li class="mb-1">
<a href="{{ route('about.faq.heimerdinger') }}"
class="text-orange-400 hover:text-orange-500">FAQ: Heimerdinger</a>
</li>
<li class="mb-1">
<a href="{{ route('posts.index') }}"
class="text-orange-400 hover:text-orange-500">Blog Posts</a>
</li>
<li class="mb-1">
<a href="{{ route('contact.index') }}"
class="text-orange-400 hover:text-orange-500">Contact</a>
</li>
</ul>
</div>
<div>
<h2 class="text-2xl font-bold text-stone-300">Champions</h2>
<ul class="mt-2">
@foreach ($champions as $champion)
<li class="mb-1">
<a href="{{ route('champions.show', $champion->slug) }}"
class="text-orange-400 hover:text-orange-500">{{ $champion->name }}</a>
</li>
@endforeach
</ul>
</div>
<div>
<h2 class="text-2xl font-bold text-stone-300">Blog Posts</h2>
<ul class="mt-2">
@foreach ($posts as $post)
<li class="mb-1">
<a href="{{ route('posts.show', $post->slug) }}"
class="text-orange-400 hover:text-orange-500">{{ $post->title }}</a>
</li>
@endforeach
</ul>
</div>
<div>
<h2 class="text-2xl font-bold text-stone-300">Skins</h2>
<ul class="mt-2">
@foreach ($skins as $skin)
<li class="mb-1">
<a href="{{ route('skins.show', $skin->slug) }}"
class="text-orange-400 hover:text-orange-500">{{ $skin->skin_name }}</a>
</li>
@endforeach
</ul>
</div>
<div>
<h2 class="text-2xl font-bold text-stone-300">Icons</h2>
<ul class="mt-2">
@foreach ($icons as $icon)
<li class="mb-1">
<a href="{{ route('assets.icons.show', $icon->slug) }}"
class="text-orange-400 hover:text-orange-500">{{ $icon->title }}</a>
</li>
@endforeach
</ul>
</div>
</div>
</div>
</div>
@endsection

View File

@@ -7,6 +7,7 @@ use App\Http\Controllers\ChampionSkinController;
use App\Http\Controllers\ContactSubmissionController; use App\Http\Controllers\ContactSubmissionController;
use App\Http\Controllers\FAQController; use App\Http\Controllers\FAQController;
use App\Http\Controllers\HomeController; use App\Http\Controllers\HomeController;
use App\Http\Controllers\HTMLSitemapController;
use App\Http\Controllers\PostsController; use App\Http\Controllers\PostsController;
use App\Http\Controllers\SaleController; use App\Http\Controllers\SaleController;
use App\Http\Controllers\SummonerEmoteController; use App\Http\Controllers\SummonerEmoteController;
@@ -29,7 +30,7 @@ use Spatie\Honeypot\ProtectAgainstSpam;
| |
*/ */
Route::get('/', static fn () => (new HomeController())->index()); Route::get('/', static fn () => (new HomeController())->index())->name('home');
// Champions // Champions
Route::get('/champions', static fn () => (new ChampionController())->index())->name('champions.index'); Route::get('/champions', static fn () => (new ChampionController())->index())->name('champions.index');
@@ -73,5 +74,8 @@ Route::post('/contact', function (ContactSubmissionRequest $request) {
return (new ContactSubmissionController())->store($request); return (new ContactSubmissionController())->store($request);
})->name('contact.store')->middleware(ProtectAgainstSpam::class); })->name('contact.store')->middleware(ProtectAgainstSpam::class);
// Site Map
Route::get('/resource/sitemap', static fn () => (new HTMLSitemapController())->index())->name('sitemap.index');
// Pulse // Pulse
Route::get(config('app.login_route'), static fn () => redirect('/pulse'))->name('login')->middleware('auth.basic'); Route::get(config('app.login_route'), static fn () => redirect('/pulse'))->name('login')->middleware('auth.basic');