@extends('layouts.public') @push('head') @endpush @section('title', $post->metaTitle ?: $post->title . ' - Lanyard Tangerang') @section('meta_description', $post->metaDescription) @section('seo_type', 'article') @section('seo_og_image', isset($post->featuredImage) ? $post->featuredImage : '/uploads/lanyardtangerang-logo.webp') @section('content') @php $img = fn ($src) => \App\Support\AssetUrl::relative($src); // Bersihkan hardcoded domain pada img src di dalam konten (contoh: localhost:8000 atau domain lama) $cleanContent = \App\Support\AssetUrl::html($post->content ?? ''); // Hapus widget "Bagikan artikel" bawaan dari hasil scraping $cleanContent = preg_replace('/]*>\s*]*>\s*Bagikan artikel\s*<\/p>[\s\S]*?]*>[\s\S]*?<\/button>\s*<\/div>\s*<\/div>/i', '', $cleanContent); $wordCount = $cleanContent ? count(preg_split('/\s+/', strip_tags($cleanContent))) : 0; $readingTime = max(1, (int) ceil($wordCount / 200)); // Pembuatan Daftar Isi (TOC) — hanya H2 & H3 $processedContent = \App\Support\AutoLinkSeo::apply($cleanContent); $toc = []; preg_match_all('/]*)>(.*?)<\/h\1>/is', $cleanContent, $matches, PREG_SET_ORDER); if (count($matches) >= 2) { $index = 0; $processedContent = preg_replace_callback('/]*)>(.*?)<\/h\1>/is', function($match) use (&$toc, &$index) { $level = (int) $match[1]; $attrs = $match[2]; $text = trim(html_entity_decode(strip_tags($match[3]), ENT_QUOTES | ENT_HTML5, 'UTF-8')); if ($text === '') return $match[0]; // Gunakan ID yang sudah ada bila tersedia, lalu pastikan tetap unik. preg_match('/\sid=["\']([^"\']+)["\']/i', $attrs, $idMatch); $slug = \Illuminate\Support\Str::slug($idMatch[1] ?? $text); $slug = $slug !== '' ? $slug : 'bagian-'.($index + 1); $baseSlug = $slug; $counter = 1; while (in_array($slug, array_column($toc, 'slug'), true)) { $slug = $baseSlug.'-'.$counter++; } $attrs = preg_replace('/\s+id=["\'][^"\']*["\']/i', '', $attrs); $toc[] = [ 'level' => $level, 'text' => $text, 'slug' => $slug ]; $index++; return ''.$match[3].''; }, $processedContent); // Build TOC HTML — collapsible details $tocTree = []; $tocStack = []; foreach ($toc as $tocItem) { while (!empty($tocStack) && $tocStack[array_key_last($tocStack)]['level'] >= $tocItem['level']) { array_pop($tocStack); } $node = ['item' => $tocItem, 'children' => []]; if (empty($tocStack)) { $tocTree[] = $node; $nodeIndex = array_key_last($tocTree); $tocStack[] = ['level' => $tocItem['level'], 'node' => &$tocTree[$nodeIndex]]; } else { $parentIndex = array_key_last($tocStack); $parent = &$tocStack[$parentIndex]['node']; $parent['children'][] = $node; $nodeIndex = array_key_last($parent['children']); $tocStack[] = ['level' => $tocItem['level'], 'node' => &$parent['children'][$nodeIndex]]; unset($parent); } } $renderToc = function (array $nodes, int $depth = 0) use (&$renderToc): string { $html = '
    '; foreach ($nodes as $node) { $item = $node['item']; $html .= '
  1. '; $html .= ''; $html .= ''; $html .= ''.e($item['text']).''; $html .= ''; if (!empty($node['children'])) { $html .= $renderToc($node['children'], $depth + 1); } $html .= '
  2. '; } return $html.'
'; }; $tocHtml = '
'; $tocHtml .= ''; $tocHtml .= ''; $tocHtml .= ''; $tocHtml .= 'Daftar Isi'; $tocHtml .= ''; $tocHtml .= ''; $tocHtml .= ''; $tocHtml .= ''; $tocHtml .= '
'; if (preg_match('/
{{-- Breadcrumb --}} {{-- Title --}}

{{ $post->title }}

{{-- Meta line: date · category · read time --}}
{{ \Carbon\Carbon::parse($post->createdAt)->translatedFormat('j F Y') }} @if($post->category) {{ $post->category->name }} @endif {{ $readingTime }} menit baca
{{-- Featured Image --}} @if($post->featuredImage)
{{ $post->title }} - Lanyard custom Tangerang {{ isset($post->category->name) ? $post->category->name : 'artikel' }}
@endif {{-- Main Content + Sidebar --}}
{{-- LEFT COLUMN --}}
{{-- Article Content --}}
{!! $processedContent !!}
{{-- Tags --}} @php $rawTags = $post->tags ?? ''; $parsedTags = collect(explode(',', $rawTags))->map(fn($t) => trim($t))->filter(); $slugify = function($s) { $s = trim($s); $s = mb_strtolower($s); $s = preg_replace('/[^a-z0-9]+/u', '-', $s); return trim($s, '-'); }; @endphp @if($parsedTags->isNotEmpty())
Tags: @foreach($parsedTags as $t) @php $tSlug = $slugify($t); @endphp #{{ $t }} @endforeach
@endif {{-- Author Card --}} @php $authorDisplayName = 'Rama Angriawan'; $authorAvatarUrl = null; $authorBioText = 'Penulis & spesialis lanyard custom di Tangerang. Berbagi tips desain, branding, event, dan panduan produksi lanyard berkualitas. Temukan artikel terbaru seputar lanyard custom Tangerang.'; if (isset($post->author) && $post->author) { $authorDisplayName = $post->author->name ?: 'Rama Angriawan'; try { if (!empty($post->author->avatar)) { $authorAvatarUrl = $img($post->author->avatar); } } catch(\Throwable $e) {} try { $b = $post->author->bio; if (!empty($b)) { $authorBioText = $b; } } catch (\Throwable $e) {} } // Override generic Admin to Rama if (stripos($authorDisplayName, 'Admin') !== false || strtolower(trim($authorDisplayName)) === 'admin tes') { $authorDisplayName = 'Rama Angriawan'; } $authorSlug = \Illuminate\Support\Str::slug($authorDisplayName); @endphp {{-- Share Widget --}}

Suka artikel ini?

Bagikan ke jaringan Anda

{{-- Comments Section --}}

Diskusi

{{ $comments->count() }} Komentar

@if(session('comment_sent'))
check_circle {{ session('comment_sent') }}
@endif {{-- Comment Form --}}
@csrf

Tinggalkan Balasan

@error('name')

{{ $message }}

@enderror @error('email')

{{ $message }}

@enderror @error('content')

{{ $message }}

@enderror

Akan dimoderasi sebelum tayang.

{{-- Comments List --}} @if($comments->isEmpty())
chat_bubble_outline

Belum ada diskusi

Jadilah yang pertama berkomentar.

@else
@foreach($comments as $comment)
{{ strtoupper(mb_substr($comment->name, 0, 1)) }}

{{ $comment->name }}

{{ $comment->createdAt->translatedFormat('j F Y') }}

{{ $comment->content }}

@endforeach
@endif
{{-- RIGHT COLUMN — Sidebar --}}
@include('components.footer') @push('schema') @include('components.schema.blog-post') @endpush @endsection @section('head') @endsection