diff --git a/resources/views/blog/index.blade.php b/resources/views/blog/index.blade.php index cd5744d..0621e31 100644 --- a/resources/views/blog/index.blade.php +++ b/resources/views/blog/index.blade.php @@ -217,6 +217,173 @@ +@push('structured-data') +@php + $siteName = setting('site_name', 'Trunçgil Teknoloji'); + $siteLogo = setting('site_logo') ? (str_starts_with(setting('site_logo'), 'http') ? setting('site_logo') : asset('storage/' . ltrim(setting('site_logo'), '/'))) : asset('assets/img/logo.png'); + $sitePhone = setting('contact_phone', '+902244431620'); + $siteEmail = setting('contact_email', 'info@truncgil.com'); + $siteAddress = setting('contact_address', 'Gaziantep Teknopark, Şahinbey, Gaziantep'); + + $socialLinksRaw = setting('social_links'); + $socialLinks = []; + if ($socialLinksRaw) { + $decoded = json_decode($socialLinksRaw, true); + if (is_array($decoded)) { + $socialLinks = array_values(array_filter($decoded)); + } elseif (is_string($socialLinksRaw)) { + $socialLinks = [$socialLinksRaw]; + } + } + if (empty($socialLinks)) { + $socialLinks = [ + 'https://twitter.com/truncgil', + 'https://facebook.com/truncgil', + 'https://instagram.com/truncgil', + 'https://youtube.com/truncgil', + 'https://linkedin.com/company/truncgil' + ]; + } + + // 1. Organization & LocalBusiness combined + $publisherData = [ + "@context" => "https://schema.org", + "@type" => "ProfessionalService", + "@id" => url('/') . "#organization", + "name" => $siteName, + "url" => url('/'), + "logo" => [ + "@type" => "ImageObject", + "url" => $siteLogo + ], + "image" => $siteLogo, + "telephone" => $sitePhone, + "email" => $siteEmail, + "address" => [ + "@type" => "PostalAddress", + "streetAddress" => $siteAddress, + "addressLocality" => "Şahinbey", + "addressRegion" => "Gaziantep", + "postalCode" => "27010", + "addressCountry" => "TR" + ], + "geo" => [ + "@type" => "GeoCoordinates", + "latitude" => 37.0274446, + "longitude" => 37.3074315 + ], + "hasMap" => "https://maps.google.com/?q=37.0274446,37.3074315", + "sameAs" => $socialLinks, + "areaServed" => [ + ["@type" => "Country", "name" => "TR"], + ["@type" => "Country", "name" => "DE"], + ["@type" => "Country", "name" => "RU"], + ["@type" => "Country", "name" => "US"], + ["@type" => "AdministrativeArea", "name" => "Gaziantep"], + ["@type" => "AdministrativeArea", "name" => "Bursa"] + ], + "priceRange" => "$$" + ]; + + // 2. Breadcrumbs + $activeCategorySlug = request()->query('category'); + $activeCategory = null; + if ($activeCategorySlug && isset($sidebarCategories)) { + $activeCategory = $sidebarCategories->firstWhere('slug', $activeCategorySlug); + } + if (!$activeCategory && $activeCategorySlug && isset($highlightCategories)) { + $activeCategory = $highlightCategories->firstWhere('slug', $activeCategorySlug); + } + $activeCategoryName = $activeCategory ? $activeCategory->name : null; + + $breadcrumbList = [ + [ + "@type" => "ListItem", + "position" => 1, + "name" => "Anasayfa", + "item" => url('/') + ], + [ + "@type" => "ListItem", + "position" => 2, + "name" => "Blog", + "item" => route('blog.index') + ] + ]; + + if ($activeCategorySlug && $activeCategoryName) { + $breadcrumbList[] = [ + "@type" => "ListItem", + "position" => 3, + "name" => $activeCategoryName, + "item" => route('blog.index', ['category' => $activeCategorySlug]) + ]; + } + + $breadcrumbs = [ + "@context" => "https://schema.org", + "@type" => "BreadcrumbList", + "itemListElement" => $breadcrumbList + ]; + + // 3. Blog List & Posts + $blogPostsList = []; + if (isset($posts) && count($posts) > 0) { + foreach ($posts as $p) { + $pTitle = method_exists($p, 'translate') ? $p->translate('title') : $p->title; + $pExcerpt = method_exists($p, 'translate') ? $p->translate('excerpt') : ($p->excerpt ?? ''); + $pContent = method_exists($p, 'translate') ? $p->translate('content') : ($p->content ?? ''); + $pExcerptText = trim(strip_tags($pExcerpt)); + if (empty($pExcerptText)) { + $pExcerptText = \Illuminate\Support\Str::limit(trim(strip_tags($pContent)), 160); + } + $pUrl = route('blog.show', $p->slug); + $pImageUrl = $p->featured_image ? asset('storage/' . $p->featured_image) : ($p->featured_image_url ?? asset('assets/img/photos/tb10.jpg')); + + $blogPostsList[] = [ + "@type" => "BlogPosting", + "headline" => $pTitle, + "description" => $pExcerptText, + "image" => $pImageUrl, + "url" => $pUrl, + "datePublished" => $p->published_at ? $p->published_at->toIso8601String() : $p->created_at->toIso8601String(), + "author" => [ + "@type" => "Person", + "name" => $p->author ? $p->author->name : 'Trunçgil' + ] + ]; + } + } + + $blogSchema = [ + "@context" => "https://schema.org", + "@type" => "Blog", + "@id" => route('blog.index') . "#blog", + "name" => $siteName . " Blog", + "description" => "Merhaba! Biz Trunçgil. Blogumuza hoş geldiniz. Burada web tasarım, yazılım geliştirme ve teknolojik yeniliklere dair ipuçlarını ve deneyimlerimizi paylaşıyoruz.", + "url" => route('blog.index'), + "publisher" => [ + "@type" => "Organization", + "name" => $siteName, + "logo" => [ + "@type" => "ImageObject", + "url" => $siteLogo + ] + ], + "blogPost" => $blogPostsList + ]; +@endphp + + + +@endpush + @push('styles')