@extends('layouts.modern') @php $locale = app()->getLocale(); // Set Carbon locale for date formatting \Carbon\Carbon::setLocale($locale); $metaTitleField = $locale === 'tr' ? 'meta_title' : 'meta_title_' . $locale; $metaDescField = $locale === 'tr' ? 'meta_description' : 'meta_description_' . $locale; $metaKeywordsField = $locale === 'tr' ? 'meta_keywords' : 'meta_keywords_' . $locale; $seoTitle = ($post->$metaTitleField ?? $post->meta_title ?? null) ?: $post->localized_title . ' - FTurkey.com'; $seoDescription = ($post->$metaDescField ?? $post->meta_description ?? null) ?: $post->localized_excerpt; $seoKeywords = $post->$metaKeywordsField ?? $post->meta_keywords ?? null; // Featured Image - FIX .webp issues $featuredImage = $post->featured_image; if ($featuredImage) { // Remove .webp extension if present $featuredImage = preg_replace('/\.webp(\?[^"\']*)?$/i', '.jpg$1', $featuredImage); // Normalize path if (!str_starts_with($featuredImage, 'http')) { $featuredImage = ltrim($featuredImage, '/'); if (!str_starts_with($featuredImage, 'images/')) { if (!str_contains($featuredImage, '/')) { $featuredImage = 'images/blog/' . $featuredImage; } else { $featuredImage = 'images/blog/' . basename($featuredImage); } } // Check if file exists if (!file_exists(public_path($featuredImage))) { $featuredImage = 'images/og-blog.jpg'; } } $seoImage = str_starts_with($featuredImage, 'http') ? $featuredImage : asset($featuredImage); } else { $seoImage = asset('images/og-blog.jpg'); $featuredImage = 'images/og-blog.jpg'; } $seoType = 'article'; // Process content - REMOVE ALL .webp and picture/source tags $rawContent = $post->localized_content; // STEP 1: Remove ALL picture and source elements completely $rawContent = preg_replace('/]*>[\s\S]*?<\/picture>/i', '', $rawContent); $rawContent = preg_replace('/]*>/i', '', $rawContent); // STEP 2: Replace ALL .webp with .jpg (ultra aggressive) $rawContent = str_ireplace('.webp', '.jpg', $rawContent); $rawContent = preg_replace('/\.webp(\?[^"\'>\s<]*)?/i', '.jpg$1', $rawContent); // STEP 3: Fix all img tags - use og-blog.jpg as placeholder (it exists) $placeholderImage = asset('images/og-blog.jpg'); $rawContent = preg_replace_callback( '/]*)>/i', function($matches) use ($placeholderImage) { $tag = $matches[0]; // Remove .webp from tag $tag = str_ireplace('.webp', '.jpg', $tag); // Add onerror if not exists if (strpos($tag, 'onerror') === false) { $tag = str_replace('>', ' onerror="this.onerror=null;this.src=\'' . $placeholderImage . '\'">', $tag); } return $tag; }, $rawContent ); // STEP 4: Extract headings for TOC preg_match_all('/]*>(.*?)<\/h[2-4]>/i', $rawContent, $headings); $tocItems = []; if (!empty($headings[0])) { foreach ($headings[0] as $index => $heading) { $level = $headings[1][$index]; $text = strip_tags($headings[2][$index]); $slug = \Illuminate\Support\Str::slug($text) . '-' . $index; $tocItems[] = ['level' => $level, 'text' => $text, 'slug' => $slug]; // Add ID to heading $rawContent = preg_replace( '/]*>' . preg_quote($headings[2][$index], '/') . '<\/h' . $level . '>/i', '' . $headings[2][$index] . '', $rawContent, 1 ); } } // STEP 5: Insert featured image in the middle of content for SEO // Split content by paragraphs and insert image after middle paragraph $paragraphs = preg_split('/(<\/p>|<\/h[1-6]>)/i', $rawContent, -1, PREG_SPLIT_DELIM_CAPTURE); $totalParagraphs = count($paragraphs); $middleIndex = floor($totalParagraphs / 2); // Find a good insertion point (after a closing

or tag) $insertionPoint = 0; $paragraphCount = 0; for ($i = 0; $i < $totalParagraphs; $i++) { if (preg_match('/<\/p>|<\/h[1-6]>/i', $paragraphs[$i])) { $paragraphCount++; if ($paragraphCount >= $middleIndex && $paragraphCount > 2) { $insertionPoint = $i + 1; break; } } } // If we found a good insertion point, insert the featured image if ($insertionPoint > 0 && $insertionPoint < $totalParagraphs) { $featuredImageHtml = '
' . '' . '
'; array_splice($paragraphs, $insertionPoint, 0, $featuredImageHtml); } $content = implode('', $paragraphs); @endphp @section('content')

{{ $post->localized_title }}

{{ $post->reading_time ?? 5 }} {{ __('common.dk okuma') }} {{ number_format($post->views_count) }} {{ __('common.görüntülenme') }} {{ $post->published_at->translatedFormat('d F Y') }} @if($post->updated_at && $post->updated_at->gt($post->published_at)) {{ __('common.Son güncelleme') }}: {{ $post->updated_at->translatedFormat('d F Y') }} @endif
{!! $content !!}
@if($post->tags->count() > 0)
{{ __('common.Etiketler') ?? 'Etiketler' }}: @foreach($post->tags as $tag) #{{ $tag->localized_name }} @endforeach
@endif
{{ __('common.Paylaş') ?? 'Paylaş' }}:
@php $shareUrl = urlencode(url()->current()); $shareTitle = urlencode($post->localized_title); $shareText = urlencode($post->localized_excerpt); @endphp
@if($relatedPosts->count() > 0)

{{ __('common.İlgili Yazılar') }}

@foreach($relatedPosts as $relatedPost)
@php $relatedImage = $relatedPost->featured_image; if ($relatedImage) { $relatedImage = preg_replace('/\.webp(\?[^"\']*)?$/i', '.jpg$1', $relatedImage); if (!str_starts_with($relatedImage, 'http')) { $relatedImage = ltrim($relatedImage, '/'); if (!str_starts_with($relatedImage, 'images/')) { $relatedImage = 'images/blog/' . basename($relatedImage); } if (!file_exists(public_path($relatedImage))) { $relatedImage = 'images/og-blog.jpg'; } } $relatedImageUrl = str_starts_with($relatedImage, 'http') ? $relatedImage : asset($relatedImage); } else { $relatedImageUrl = asset('images/og-blog.jpg'); } @endphp {{ $relatedPost->featured_image_alt ?? $relatedPost->localized_title }}

{{ $relatedPost->localized_title }}

{{ $relatedPost->localized_excerpt }}

{{ __('common.Devamını Oku') }}
@endforeach
@endif

{{ __('common.Türkiye\'de İş Kurma Sürecinizde Yardıma mı İhtiyacınız Var?') }}

{{ __('common.Uzman ekibimiz size özel çözümler sunmak için hazır') }}

{{ __('common.Ücretsiz Danışmanlık Alın') }}
{{-- Structured Data for Blog Post - Article Schema --}} {!! App\Helpers\SeoHelper::generateStructuredData('article', [ 'headline' => $post->localized_title, 'description' => $post->localized_excerpt, 'image' => $seoImage, 'datePublished' => $post->published_at->toIso8601String(), 'dateModified' => $post->updated_at->toIso8601String(), 'url' => url()->current(), 'author' => [ '@type' => 'Person', 'name' => $post->author->name ?? 'FTurkey.com Team' ], 'publisher' => [ '@type' => 'Organization', 'name' => 'FTurkey.com', 'logo' => [ '@type' => 'ImageObject', 'url' => asset('images/logo.png') ] ] ]) !!} {{-- FAQ Schema --}} @if(isset($faqs) && count($faqs) > 0) @php $faqQuestions = []; foreach ($faqs as $faq) { $faqQuestions[] = [ '@type' => 'Question', 'name' => $faq['question'], 'acceptedAnswer' => [ '@type' => 'Answer', 'text' => $faq['answer'] ] ]; } @endphp {!! App\Helpers\SeoHelper::generateStructuredData('faq', ['questions' => $faqQuestions]) !!} @endif {{-- HowTo Schema --}} @if(isset($howToSteps) && count($howToSteps) > 0) {!! App\Helpers\SeoHelper::generateHowTo( $post->localized_title, $post->localized_excerpt, $howToSteps, [ 'image' => $seoImage, 'totalTime' => 'PT' . ($post->reading_time ?? 10) . 'M' ] ) !!} @endif {!! App\Helpers\SeoHelper::generateBreadcrumb([ ['name' => __('common.Ana Sayfa'), 'url' => url('/')], ['name' => __('common.Blog'), 'url' => route('blog.index')], ['name' => $post->localized_title, 'url' => url()->current()] ]) !!} @endsection