seo fixes

This commit is contained in:
2026-08-09 12:43:21 +03:00
parent bed4c48900
commit 443ff374c3
5 changed files with 138 additions and 2 deletions
+15 -1
View File
@@ -6,6 +6,7 @@ use App\Models\Tool;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class ToolController extends Controller
{
@@ -72,7 +73,7 @@ class ToolController extends Controller
'tool' => $tool,
'related' => $related,
'title' => $tool->name.' — AI Tools — '.config('app.name'),
'description' => str($tool->description)->limit(155, '')->toString(),
'description' => $this->metaDescription($tool->description),
'canonical' => route('tools.show', $tool),
'image' => $tool->logo_url,
]);
@@ -86,4 +87,17 @@ class ToolController extends Controller
return redirect()->away($tool->url);
}
/**
* Truncate to ~155 chars without cutting a word in half. Google appends
* its own ellipsis when it truncates in search results, so we don't add one.
*/
private function metaDescription(string $description, int $limit = 155): string
{
if (Str::length($description) <= $limit) {
return $description;
}
return Str::of($description)->limit($limit, '')->beforeLast(' ')->toString();
}
}