Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer collective, backed by the Pireon OAuth identity server. The public site is a separate, server-rendered application consuming /api/public/v1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
70 lines
2.0 KiB
PHP
70 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\Health\Checks;
|
|
|
|
use App\Models\Page;
|
|
use App\Models\Project;
|
|
use App\Support\Health\Check;
|
|
use App\Support\Health\Finding;
|
|
|
|
/**
|
|
* Published work with nothing for a search result or a shared link to show.
|
|
*
|
|
* Without `meta_description` the frontend has nothing to put in the meta tag
|
|
* and the snippet gets invented from the body; without a cover there is no
|
|
* image when the link is pasted into a chat. For a collective whose whole
|
|
* point is being found and shared, that is the difference between a project
|
|
* being read and being scrolled past.
|
|
*/
|
|
class IncompleteSeo implements Check
|
|
{
|
|
public function key(): string
|
|
{
|
|
return 'incomplete-seo';
|
|
}
|
|
|
|
public function permission(): ?string
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public function run(): Finding
|
|
{
|
|
$default = (string) config('locales.default');
|
|
$count = 0;
|
|
$samples = [];
|
|
|
|
foreach (Project::query()->published()->get(['id', 'title', 'meta_description', 'cover_image']) as $project) {
|
|
$missing = [];
|
|
|
|
if (blank($project->getTranslation('meta_description', $default, false))) {
|
|
$missing[] = __('health.bits.description');
|
|
}
|
|
|
|
if (blank($project->cover_image)) {
|
|
$missing[] = __('health.bits.cover');
|
|
}
|
|
|
|
if ($missing === []) {
|
|
continue;
|
|
}
|
|
|
|
$count++;
|
|
$samples[] = $project->getTranslation('title', $default, false).' ('.implode(', ', $missing).')';
|
|
}
|
|
|
|
foreach (Page::query()->published()->get(['id', 'title', 'meta_description']) as $page) {
|
|
if (filled($page->getTranslation('meta_description', $default, false))) {
|
|
continue;
|
|
}
|
|
|
|
$count++;
|
|
$samples[] = $page->getTranslation('title', $default, false).' ('.__('health.bits.description').')';
|
|
}
|
|
|
|
return Finding::problem($this->key(), $count, samples: $samples);
|
|
}
|
|
}
|