127 lines
5.3 KiB
PHP
127 lines
5.3 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/includes/site.php';
|
|
require_once __DIR__ . '/includes/layout.php';
|
|
|
|
boot_site();
|
|
|
|
$slug = trim((string)($_GET['slug'] ?? ''));
|
|
$post = $slug !== '' ? fetch_post_by_slug($slug) : null;
|
|
|
|
if ($post === null) {
|
|
http_response_code(404);
|
|
render_page_start([
|
|
'title' => 'Artikel tidak ditemukan',
|
|
'description' => 'Halaman artikel yang diminta tidak ditemukan.',
|
|
'canonical' => current_url(),
|
|
'robots' => 'noindex,follow',
|
|
]);
|
|
?>
|
|
<main id="main-content" class="page-wrap py-5">
|
|
<div class="container">
|
|
<section class="empty-state">
|
|
<h1 class="h3 mb-2">Artikel tidak ditemukan</h1>
|
|
<p class="mb-3">Slug yang diminta tidak tersedia. Silakan kembali ke blog untuk melihat artikel yang tersedia.</p>
|
|
<div class="d-flex flex-wrap gap-2 justify-content-center">
|
|
<a class="btn btn-dark" href="blog.php">Kembali ke blog</a>
|
|
<a class="btn btn-outline-dark" href="index.php">Ke beranda</a>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</main>
|
|
<?php
|
|
render_page_end();
|
|
return;
|
|
}
|
|
|
|
$canonicalUrl = canonical_for(post_url($post));
|
|
$relatedPosts = fetch_related_posts((int)$post['id'], (string)$post['category'], 3);
|
|
$description = excerpt_text((string)$post['excerpt'], 155);
|
|
|
|
render_page_start([
|
|
'title' => (string)$post['title'],
|
|
'description' => $description,
|
|
'canonical' => $canonicalUrl,
|
|
'keywords' => 'artikel apknusa, blog android, backlink apknusa, ' . (string)$post['category'],
|
|
'json_ld' => [
|
|
'@context' => 'https://schema.org',
|
|
'@type' => 'BlogPosting',
|
|
'headline' => (string)$post['title'],
|
|
'description' => $description,
|
|
'datePublished' => date(DATE_ATOM, strtotime((string)$post['published_at'])),
|
|
'dateModified' => date(DATE_ATOM, strtotime((string)$post['updated_at'])),
|
|
'mainEntityOfPage' => $canonicalUrl,
|
|
'author' => [
|
|
'@type' => 'Organization',
|
|
'name' => project_name(),
|
|
],
|
|
'publisher' => [
|
|
'@type' => 'Organization',
|
|
'name' => project_name(),
|
|
],
|
|
],
|
|
]);
|
|
?>
|
|
<main id="main-content" class="page-wrap py-5">
|
|
<div class="container">
|
|
<div class="row g-4">
|
|
<div class="col-lg-8">
|
|
<article class="article-shell">
|
|
<div class="article-meta-top d-flex flex-wrap gap-2 align-items-center mb-3">
|
|
<a class="tag-badge text-decoration-none" href="blog.php?category=<?= rawurlencode((string)$post['category']) ?>"><?= e((string)$post['category']) ?></a>
|
|
<span class="muted-meta"><?= e((string)format_article_date((string)$post['published_at'])) ?></span>
|
|
<span class="muted-meta"><?= e((string)reading_time_minutes((string)$post['content'])) ?> menit baca</span>
|
|
</div>
|
|
<h1 class="article-title mb-3"><?= e((string)$post['title']) ?></h1>
|
|
<p class="article-lead"><?= e((string)$post['excerpt']) ?></p>
|
|
<div class="article-body">
|
|
<?= render_post_content((string)$post['content']) ?>
|
|
</div>
|
|
<div class="cta-panel mt-4">
|
|
<div>
|
|
<div class="card-label">Langkah berikutnya</div>
|
|
<h2 class="h4 mb-2">Lanjutkan ke website utama</h2>
|
|
<p class="mb-0">Setelah membaca ringkasan ini, arahkan pengunjung ke apknusa.com untuk melihat referensi atau konten utama yang lebih lengkap.</p>
|
|
</div>
|
|
<a class="btn btn-dark btn-cta" href="<?= e((string)$post['cta_url']) ?>" target="_blank" rel="noopener noreferrer"><?= e((string)$post['cta_text']) ?></a>
|
|
</div>
|
|
</article>
|
|
</div>
|
|
<div class="col-lg-4">
|
|
<aside class="sidebar-stack d-flex flex-column gap-3">
|
|
<div class="panel-card">
|
|
<div class="card-label">Arah navigasi</div>
|
|
<h2 class="h5 mb-2">Alur pengunjung</h2>
|
|
<ol class="flow-list mb-0 ps-3">
|
|
<li>Baca ringkasan topik</li>
|
|
<li>Pahami konteks utama</li>
|
|
<li>Klik menuju apknusa.com</li>
|
|
</ol>
|
|
</div>
|
|
<div class="panel-card">
|
|
<div class="card-label">Artikel terkait</div>
|
|
<div class="related-list d-flex flex-column gap-3 mt-3">
|
|
<?php foreach ($relatedPosts as $related): ?>
|
|
<article class="related-item">
|
|
<span class="muted-meta d-block mb-1"><?= e((string)$related['category']) ?></span>
|
|
<h3 class="h6 mb-1"><a href="<?= e(post_url($related)) ?>"><?= e((string)$related['title']) ?></a></h3>
|
|
<p class="small text-secondary mb-0"><?= e((string)excerpt_text((string)$related['excerpt'], 92)) ?></p>
|
|
</article>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
<div class="panel-card">
|
|
<div class="card-label">Link cepat</div>
|
|
<div class="d-flex flex-wrap gap-2 mt-2">
|
|
<a class="btn btn-outline-dark btn-sm" href="blog.php">Kembali ke blog</a>
|
|
<a class="btn btn-outline-dark btn-sm" href="<?= e(APKNUSA_URL) ?>" target="_blank" rel="noopener noreferrer">Buka apknusa.com</a>
|
|
</div>
|
|
</div>
|
|
</aside>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
<?php render_page_end(); ?>
|