{{-- Blog Preview — Editorial Showcase Premium (Linear/Stripe/Vercel/Apple) --}} @php use App\Models\Post; use Illuminate\Support\Facades\Cache; $posts = Cache::store(config('cache.public_store', 'file'))->remember('home_posts', 3600, function () { return Post::with('category')->where('published', true)->orderBy('createdAt', 'desc')->take(3)->get(); }); if ($posts->isEmpty()) { $posts = collect([ (object) ['title' => 'Pentingnya Lanyard untuk Keamanan Event Skala Besar yang Profesional','slug' => 'pentingnya-lanyard-event','featuredImage' => null,'category' => (object) ['name' => 'ARTIKEL'],'createdAt' => now()->subDays(3),'readingTime' => 5,'content'=>''], (object) ['title' => 'Tips Mendesain Lanyard Elegan yang Mencerminkan Identitas Brand','slug' => 'tips-mendesain-lanyard','featuredImage' => null,'category' => (object) ['name' => 'GUIDE'],'createdAt' => now()->subDays(8),'readingTime' => 4,'content'=>''], (object) ['title' => 'Material Tissue vs Polyester: Mana yang Terbaik untuk Kebutuhan Anda','slug' => 'tissue-vs-polyester','featuredImage' => null,'category' => (object) ['name' => 'NEWS'],'createdAt' => now()->subDays(14),'readingTime' => 6,'content'=>''], ]); } $img = fn ($src) => \App\Support\AssetUrl::relative($src); $badge = function($name){ $name = strtoupper(trim($name)); if ($name === '') { $name = 'ARTIKEL'; } $map = ['EVENT'=>'NEWS','EVENTS'=>'NEWS','BRANDING'=>'GUIDE','MATERIAL'=>'TIPS','UPDATE'=>'ARTIKEL','BERITA'=>'NEWS','TIPS'=>'TIPS','PANDUAN'=>'GUIDE','ARTIKEL'=>'ARTIKEL','GUIDE'=>'GUIDE','NEWS'=>'NEWS']; if (isset($map[$name])) { return $map[$name]; } return $name; }; $formatDate = function($date){ if (empty($date)) { return null; } try{ if ($date instanceof \Carbon\Carbon) { $d = $date; } else { $d = \Carbon\Carbon::parse($date); } return $d->locale('id')->translatedFormat('d F Y'); } catch (\Throwable $e) { return null; } }; @endphp

Update & Insight

Panduan, tips, dan cerita di balik proses produksi lanyard premium kami.

Lihat Semua Artikel
@foreach ($posts as $post) @php $catName = 'ARTIKEL'; if (isset($post->category) && isset($post->category->name) && !empty($post->category->name)) { $catName = $post->category->name; } $cat = $badge($catName); $rawDate = null; if (isset($post->createdAt)) { $rawDate = $post->createdAt; } elseif (isset($post->created_at)) { $rawDate = $post->created_at; } $dateLabel = $formatDate($rawDate); $feat = null; if (isset($post->featuredImage)) { $feat = $post->featuredImage; } $image = $img($feat); $content = ''; if (isset($post->content)) { $content = $post->content; } $wordCount = 0; if (!empty($content)) { $plain = strip_tags($content); $wordCount = str_word_count($plain); } $calcRt = 0; if ($wordCount > 0) { $calcRt = (int) ceil($wordCount / 200); } $fallbackRt = $calcRt > 0 ? $calcRt : 5; $rt = $fallbackRt; if (isset($post->readingTime) && !empty($post->readingTime)) { $rt = (int) $post->readingTime; } if ($rt < 1) { $rt = 1; } $slug = ''; if (isset($post->slug)) { $slug = $post->slug; } $title = ''; if (isset($post->title)) { $title = $post->title; } @endphp @endforeach