@extends('frontend.layouts.app')
@php
/* ---------- SEO values ---------- */
$seoTitle = trim((string) ($page->meta_title ?: $page->title));
$seoDesc = $page->seoDescription();
$seoKeys = trim((string) $page->meta_keywords);
$seoImg = $page->ogImageUrl();
$seoUrl = $page->canonicalUrl();
$robots = $page->robotsContent();
$schema = (string) ($page->schema_type ?: 'WebPage');
$isArticle = in_array($schema, ['Article', 'BlogPosting'], true);
/* Safe for HTML attribute context (@yield is not escaped by Blade). */
$attr = fn ($s) => str_replace(['&', '"'], ['&', '"'], (string) $s);
/* Safe for element content (the
tag). */
$elem = fn ($s) => str_replace(['&', '<', '>'], ['&', '<', '>'], (string) $s);
/* ---------- JSON-LD structured data ---------- */
$jsonld = [
'@context' => 'https://schema.org',
'@type' => $schema,
'name' => $page->title,
'description' => $seoDesc,
'url' => $seoUrl,
'inLanguage' => 'en',
'isPartOf' => [
'@type' => 'WebSite',
'name' => 'The Braj Dham Seva Trust',
'url' => url('/'),
],
'publisher' => [
'@type' => 'Organization',
'name' => 'The Braj Dham Seva Trust',
'logo' => [
'@type' => 'ImageObject',
'url' => asset('images/logo/the-braj-logo.jpg'),
],
],
'datePublished' => optional($page->created_at)->toIso8601String(),
'dateModified' => optional($page->updated_at)->toIso8601String(),
];
if ($isArticle) {
$jsonld['headline'] = $page->title;
$jsonld['mainEntityOfPage'] = ['@type' => 'WebPage', '@id' => $seoUrl];
}
if ($seoImg) {
$jsonld['image'] = $seoImg;
}
@endphp
{{-- ---- Page-level SEO meta ---- --}}
@section('title', $elem($seoTitle) . ' - The Braj Dham Seva Trust')
@section('meta_description', $attr($seoDesc))
@section('og_title', $attr($seoTitle))
@section('og_description', $attr($seoDesc))
@section('og_url', $attr($seoUrl))
@section('og_type', $isArticle ? 'article' : 'website')
@section('robots', $attr($robots))
@section('canonical', $attr($seoUrl))
@if($seoKeys !== '')
@section('meta_keywords', $attr($seoKeys))
@endif
@if($seoImg)
@section('og_image', $attr($seoImg))
@endif
@section('jsonld')
@endsection
@section('content')
{{ $page->title ?? 'Page' }}
{!! $page->content ?? '' !!}
@endsection