@php use App\Models\PageSeo; /** @var string $slug */ /** @var string $path */ /** @var array $defaults */ $seo = $seo ?? PageSeo::forSlug($slug); $path = $path ?? '/'; $defaults = $defaults ?? []; $defaultTitle = (string) ($defaults['title'] ?? config('app.name')); $defaultDescription = (string) ($defaults['description'] ?? ''); $appendSiteName = (bool) ($defaults['append_site_name'] ?? false); $metaTitle = page_seo_value($seo, 'meta_title', ''); $metaDescription = page_seo_value($seo, 'meta_description', ''); $ogTitle = page_seo_value($seo, 'og_title', ''); $ogDescription = page_seo_value($seo, 'og_description', ''); if ($metaTitle === '') { $metaTitle = $defaultTitle; if ($appendSiteName && !str_contains($metaTitle, (string) config('app.name'))) { $metaTitle .= ' - ' . config('app.name'); } } if ($metaDescription === '') { $metaDescription = $defaultDescription; } if ($ogTitle === '') { $ogTitle = $metaTitle; } if ($ogDescription === '') { $ogDescription = $metaDescription !== '' ? $metaDescription : $defaultDescription; } $canonical = $seo && $seo->canonical_url ? $seo->canonical_url : rtrim((string) config('app.url'), '/') . __url($path); $ogUrl = rtrim((string) config('app.url'), '/') . __url($path); $ogImage = (string) ($defaults['og_image'] ?? '/images/android-chrome-512x512.png'); @endphp {{ $metaTitle }} @if($metaDescription !== '') @endif @if($ogDescription !== '') @endif