@extends('layouts.main') @section('title', $post->meta_title ?? $post->title . ' - Linkie.dev') @section('meta') {{-- SEO Meta Tags: Comprehensive SEO optimization for search engines and social media --}} {{-- Meta Description: Primary description for search engines, fallback to excerpt or default --}} {{-- Canonical URL: Prevents duplicate content issues, points to the original post URL --}} {{-- Open Graph Tags: For Facebook, LinkedIn, and other social platforms --}} @if($post->featured_image) {{-- Open Graph Image: Featured image for social media previews --}} @endif {{-- Twitter Card Tags: Optimized for Twitter sharing --}} @if($post->featured_image) {{-- Twitter Image: Featured image for Twitter card preview --}} @endif {{-- Article Meta: Additional article-specific metadata --}} @if($post->published_at) @endif @if($post->category) @endif @endsection @section('content') {{-- Single Blog Post Page: Premium affiliate-style article layout with sidebar --}}
{{-- Main Container: Max width 7xl, centered, responsive padding --}}
{{-- Back Link: Navigation button with icon, accent color, hover effect, bottom margin --}} Back to Blog {{-- Featured Image: Full width hero image above content --}} @if($post->featured_image)
{{ $post->title }}
@endif {{-- Main Layout Grid: 3 columns on XL screens, 1 column on mobile --}}
{{-- Main Content Column: 3 columns on XL, full width on mobile --}}
{{-- Article Header: Title, category badge, date, rating --}}
{{-- Category Badge: Conditional rendering, accent color --}} @if($post->category && strtolower($post->category) !== 'imported') {{ $post->category }} @endif {{-- Article Title: Large, bold, heading font, white text --}}

{{ $post->title }}

{{-- Meta Info: Date and rating in flex layout --}}
{{ $post->published_at?->format('F d, Y') ?? $post->created_at->format('F d, Y') }}
{{-- Rating Display: Star rating component --}}
{{-- CTA Block Position 1: Immediately after article header --}} @php // Get affiliate link from database field first, then extract from content as fallback $affiliateLink = $post->affiliate_link ?? ''; $ctaText = $post->cta_section ?? ''; // If not in database, try to extract from content if (empty($affiliateLink) || empty($ctaText)) { $content = html_entity_decode($post->content, ENT_QUOTES | ENT_HTML5, 'UTF-8'); // Extract affiliate link from content if not in database if (empty($affiliateLink)) { // First, try to extract from cta-section div (most reliable) if (preg_match('/]*class=["\']cta-section["\'][^>]*>.*?]*href=["\']([^"\']+)["\'][^>]*>/s', $content, $matches)) { $affiliateLink = $matches[1]; } // If not found in cta-section, try any link with target="_blank" and rel="nofollow" if (empty($affiliateLink)) { if (preg_match('/]*href=["\']([^"\']+)["\'][^>]*(?:target=["\']_blank["\']|rel=["\']nofollow["\'])/s', $content, $matches)) { $affiliateLink = $matches[1]; } } // Last resort: any link with target="_blank" if (empty($affiliateLink)) { if (preg_match('/]*href=["\']([^"\']+)["\'][^>]*target=["\']_blank["\']/s', $content, $matches)) { $affiliateLink = $matches[1]; } } // Final fallback: extract any external URL from anchor tags (http/https) if (empty($affiliateLink)) { if (preg_match_all('/]*href=["\'](https?:\/\/[^"\']+)["\'][^>]*>/s', $content, $allMatches)) { // Take the first external URL found foreach ($allMatches[1] as $url) { // Skip internal links and common non-affiliate domains if (!preg_match('/\.(jpg|jpeg|png|gif|pdf|zip)$/i', $url) && !preg_match('/^(mailto:|tel:|#)/', $url)) { $affiliateLink = $url; break; } } } } } // Extract CTA text from content if not in database if (empty($ctaText)) { if (preg_match('/]*class=["\']cta-section["\'][^>]*>.*?]*>(.*?)<\/h2>/s', $content, $ctaMatches)) { $ctaText = strip_tags($ctaMatches[1]); } } } @endphp @if(!empty($affiliateLink) && filter_var($affiliateLink, FILTER_VALIDATE_URL)) @endif {{-- Extract Content Sections: Parse HTML to extract pros, cons, features, FAQs --}} @php // Ensure content is decoded for parsing $content = html_entity_decode($post->content, ENT_QUOTES | ENT_HTML5, 'UTF-8'); // Extract Pros $pros = []; if (preg_match('/

Pros<\/h2>
    (.*?)<\/ul>/s', $content, $matches)) { preg_match_all('/
  • (.*?)<\/li>/', $matches[1], $proMatches); $pros = array_map('strip_tags', $proMatches[1]); } // Extract Cons $cons = []; if (preg_match('/

    Cons<\/h2>
      (.*?)<\/ul>/s', $content, $matches)) { preg_match_all('/
    • (.*?)<\/li>/', $matches[1], $conMatches); $cons = array_map('strip_tags', $conMatches[1]); } // Extract Features $features = []; if (preg_match('/

      Features<\/h2>
        (.*?)<\/ul>/s', $content, $matches)) { preg_match_all('/
      • (.*?)<\/li>/', $matches[1], $featureMatches); $features = array_map('strip_tags', $featureMatches[1]); } // Extract FAQs $faqs = []; if (preg_match('/

        Frequently Asked Questions<\/h2>(.*?)(?=(.*?)<\/h3>\s*

        (.*?)<\/p>/s', $faqSection[1], $faqMatches); for ($i = 0; $i < count($faqMatches[1]); $i++) { $faqs[] = [ 'question' => strip_tags($faqMatches[1][$i]), 'answer' => strip_tags($faqMatches[2][$i]) ]; } } // Remove pros/cons/features/faqs/cta sections from main content for cleaner display // But keep the headings for TOC generation $cleanContent = $content; $cleanContent = preg_replace('/

        Pros<\/h2>
          .*?<\/ul>/s', '', $cleanContent); $cleanContent = preg_replace('/

          Cons<\/h2>
            .*?<\/ul>/s', '', $cleanContent); $cleanContent = preg_replace('/

            Features<\/h2>
              .*?<\/ul>/s', '', $cleanContent); $cleanContent = preg_replace('/

              Frequently Asked Questions<\/h2>.*?(?=]*>.*?<\/div>/s', '', $cleanContent); // Ensure content is properly decoded (handle double encoding) $cleanContent = html_entity_decode($cleanContent, ENT_QUOTES | ENT_HTML5, 'UTF-8'); @endphp {{-- Table of Contents: Auto-generated from headings --}}

              Table of Contents

                {{-- TOC items will be generated by JavaScript --}}
              {{-- Main Article Content: Prose styling with proper typography --}}
              {!! $cleanContent !!}
              {{-- Pros & Cons Cards: Modern side-by-side cards --}} @if(!empty($pros) || !empty($cons))
              {{-- Pros Card: Green accent border and text --}} @if(!empty($pros))

              Pros

                @foreach($pros as $pro)
              • {{ $pro }}
              • @endforeach
              @endif {{-- Cons Card: Red accent border and text --}} @if(!empty($cons))

              Cons

                @foreach($cons as $con)
              • {{ $con }}
              • @endforeach
              @endif
              @endif {{-- Features Section: Grid layout for features --}} @if(!empty($features))

              Key Features

              @foreach($features as $feature)
              {{ $feature }}
              @endforeach
              @endif {{-- CTA Block Position 3: At the end of article, before FAQ --}} @if(!empty($affiliateLink) && filter_var($affiliateLink, FILTER_VALIDATE_URL)) @endif {{-- FAQ Accordion: Collapsible FAQ section --}} @if(!empty($faqs))
              @endif {{-- Related Articles Section: SEO-friendly internal linking --}} @if($relatedPosts->count() > 0)

              Related Articles

              @foreach($relatedPosts as $relatedPost) @endforeach
              @else {{-- Fallback: Show recent posts if no related posts --}} @php $recentPosts = \App\Models\Post::published() ->where('id', '!=', $post->id) ->latest('published_at') ->limit(3) ->get(); @endphp @if($recentPosts->count() > 0)

              Latest Articles

              @foreach($recentPosts as $recentPost) @endforeach
              @endif @endif

{{-- Sidebar Column: Affiliate card and CTA, only visible on XL screens --}}
{{-- CTA Block in Sidebar: Prominent call-to-action --}} @if(!empty($affiliateLink) && filter_var($affiliateLink, FILTER_VALIDATE_URL)) @endif {{-- Affiliate Product Card --}}
@push('scripts') @endpush @endsection