Update
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\MemeMedia;
|
||||
use Artesaos\SEOTools\Facades\SEOMeta;
|
||||
use Artesaos\SEOTools\Facades\OpenGraph;
|
||||
use Artesaos\SEOTools\Facades\TwitterCard;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
@@ -41,6 +44,47 @@ private function getMemes(?string $search = null): Response
|
||||
|
||||
$memes = $query->cursorPaginate(24);
|
||||
|
||||
// Set up SEO meta tags
|
||||
$title = $search ? ucfirst($search) . " Memes in MEMEFA.ST" : 'Meme Library - Thousands of Video Meme Templates';
|
||||
|
||||
if ($search) {
|
||||
// Get SEO descriptions from config
|
||||
$descriptions = config('platform.seo_descriptions.search_descriptions', []);
|
||||
|
||||
// Use deterministic selection based on search term hash
|
||||
$searchHash = crc32($search);
|
||||
$descriptionIndex = abs($searchHash) % count($descriptions);
|
||||
$descriptionTemplate = $descriptions[$descriptionIndex];
|
||||
|
||||
// Replace keyword placeholder
|
||||
$description = str_replace('__KEYWORD__', $search, $descriptionTemplate);
|
||||
} else {
|
||||
$description = 'Browse thousands of video meme templates ready for TikTok, Instagram Reels, Threads and YouTube Shorts. Create viral content in minutes with our meme editor.';
|
||||
}
|
||||
|
||||
SEOMeta::setTitle($title, false);
|
||||
SEOMeta::setDescription($description);
|
||||
SEOMeta::setCanonical(request()->url());
|
||||
|
||||
// Add pagination rel links
|
||||
if ($memes->previousPageUrl()) {
|
||||
SEOMeta::addMeta('link:prev', $memes->previousPageUrl(), 'rel');
|
||||
}
|
||||
if ($memes->nextPageUrl()) {
|
||||
SEOMeta::addMeta('link:next', $memes->nextPageUrl(), 'rel');
|
||||
}
|
||||
|
||||
// OpenGraph tags
|
||||
OpenGraph::setTitle($title);
|
||||
OpenGraph::setDescription($description);
|
||||
OpenGraph::setUrl(request()->url());
|
||||
OpenGraph::addProperty('type', 'website');
|
||||
|
||||
// Twitter Card
|
||||
TwitterCard::setTitle($title);
|
||||
TwitterCard::setDescription($description);
|
||||
TwitterCard::setType('summary_large_image');
|
||||
|
||||
// Get available types for filter
|
||||
$types = MemeMedia::where('is_enabled', true)
|
||||
->distinct()
|
||||
@@ -65,6 +109,7 @@ private function getMemes(?string $search = null): Response
|
||||
'filters' => [
|
||||
'search' => $search,
|
||||
],
|
||||
'dynamicDescription' => $search ? $description : null,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -104,7 +149,29 @@ public function show(string $slug): Response
|
||||
$relatedMemes = $relatedMemes->merge($randomMemes);
|
||||
}
|
||||
|
||||
//dd($meme);
|
||||
// Set up SEO meta tags for individual meme page
|
||||
$title = "{$meme->name} - Make Video Memes with MEMEFA.ST";
|
||||
$description = $meme->description
|
||||
? "This meme is about: {$meme->description}."
|
||||
: "Create {$meme->name} video memes with our online editor. Perfect for TikTok, Instagram Reels, and YouTube Shorts.";
|
||||
|
||||
SEOMeta::setTitle($title, false);
|
||||
SEOMeta::setDescription($description);
|
||||
SEOMeta::setCanonical(request()->url());
|
||||
SEOMeta::addKeyword(collect([$meme->keywords, $meme->action_keywords, $meme->emotion_keywords, $meme->misc_keywords])->flatten()->filter()->implode(', '));
|
||||
|
||||
// OpenGraph tags
|
||||
OpenGraph::setTitle($title);
|
||||
OpenGraph::setDescription($description);
|
||||
OpenGraph::setUrl(request()->url());
|
||||
//OpenGraph::addProperty('type', 'video.other');
|
||||
//OpenGraph::addImage($meme->webp_url);
|
||||
|
||||
// Twitter Card
|
||||
TwitterCard::setTitle($title);
|
||||
TwitterCard::setDescription($description);
|
||||
//TwitterCard::setType('summary_large_image');
|
||||
//TwitterCard::setImage($meme->webp_url);
|
||||
|
||||
return Inertia::render('memes/show', [
|
||||
'meme' => $meme,
|
||||
|
||||
Reference in New Issue
Block a user