@php $photo = $page->photos->first(); $photoUrl = ($photo && $photo->filename) ? url('assets/uploads/' . $photo->filename) : \App\Models\Page::blogPlaceholderImageUrl(); $author = $page->author; $authorProfile = $author ? $author->authorProfile : null; $authorName = ($author && $author->name) ? $author->name : 'SEO Specialist Kenya'; $authorUrl = ($authorProfile && $authorProfile->slug) ? url('author/' . $authorProfile->slug) : url('/'); $injectBeforeH2 = function (string $html, int $h2Index, string $block): string { if ($html === '' || $block === '') { return $html; } if (!preg_match_all('/]*>/i', $html, $matches, PREG_OFFSET_CAPTURE)) { return $html; } if (!isset($matches[0][$h2Index - 1])) { return $html; } $pos = $matches[0][$h2Index - 1][1]; return substr($html, 0, $pos) . $block . substr($html, $pos); }; $blogCtaRevenue = ''; $blogCtaLeadgen = ''; $blogBodyHtml = $page->description ?? ''; $blogBodyHtml = $injectBeforeH2($blogBodyHtml, 5, $blogCtaLeadgen); $blogBodyHtml = $injectBeforeH2($blogBodyHtml, 2, $blogCtaRevenue); @endphp @extends('layouts.app', [ 'title' => $page->metatitle, 'keywords' => $page->keywords, 'description' => $page->metadescription, 'image' => $photoUrl, 'canonical' => url('blog/'.$page->slug) ]) @section('content')

{{ $page->name }}

Last updated @if($page->updated_at) @endif by {{ $authorName }}

{{ $page->readingTimeLabel() }}

{!! $blogBodyHtml !!}
@endsection