119 lines
5.5 KiB
PHP
119 lines
5.5 KiB
PHP
<?php
|
|
require_once __DIR__ . '/db/config.php';
|
|
|
|
$slug = $_GET['slug'] ?? null;
|
|
if (!$slug) {
|
|
header('Location: blog.php');
|
|
exit();
|
|
}
|
|
|
|
// Fetch the blog post
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("SELECT * FROM blog_posts WHERE slug = ?");
|
|
$stmt->execute([$slug]);
|
|
$post = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if (!$post) {
|
|
// Optional: redirect to a 404 page
|
|
header('Location: blog.php');
|
|
exit();
|
|
}
|
|
|
|
$project_name = htmlspecialchars($post['title']);
|
|
$project_description = htmlspecialchars(substr($post['content'], 0, 160));
|
|
$project_keywords = "blog, articles, finance, web development";
|
|
$project_image_url = "https://project-screens.s3.amazonaws.com/screenshots/30971/app-hero-20251016-105317.png";
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title><?php echo $project_name; ?></title>
|
|
<meta name="description" content="<?php echo $project_description; ?>">
|
|
<meta name="keywords" content="<?php echo htmlspecialchars($project_keywords); ?>">
|
|
|
|
<!-- Open Graph / Facebook -->
|
|
<meta property="og:type" content="article">
|
|
<meta property="og:title" content="<?php echo $project_name; ?>">
|
|
<meta property="og:description" content="<?php echo $project_description; ?>">
|
|
<meta property="og:image" content="<?php echo htmlspecialchars($project_image_url); ?>">
|
|
|
|
<!-- Twitter -->
|
|
<meta property="twitter:card" content="summary_large_image">
|
|
<meta property="twitter:title" content="<?php echo $project_name; ?>">
|
|
<meta property="twitter:description" content="<?php echo $project_description; ?>">
|
|
<meta property="twitter:image" content="<?php echo htmlspecialchars($project_image_url); ?>">
|
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
<script src="https://unpkg.com/feather-icons"></script>
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-dark fixed-top">
|
|
<div class="container">
|
|
<a class="navbar-brand" href="index.php">Your Name</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav ms-auto">
|
|
<li class="nav-item"><a class="nav-link" href="index.php#home">Home</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="index.php#about">About</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="index.php#portfolio">Portfolio</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="blog.php">Blog</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="index.php#contact">Contact</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="/admin" target="_blank">Admin</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<main class="container mt-5 pt-5">
|
|
<div class="row justify-content-center">
|
|
<div class="col-lg-9">
|
|
<article class="blog-post">
|
|
<header class="post-header">
|
|
<h1 class="mb-3"><?php echo htmlspecialchars($post['title']); ?></h1>
|
|
<div class="post-meta">Posted on <?php echo date('F j, Y', strtotime($post['created_at'])); ?></div>
|
|
</header>
|
|
<section class="post-content mb-5">
|
|
<?php echo nl2br($post['content']); ?>
|
|
</section>
|
|
<div class="share-section">
|
|
<h4>Share This Post</h4>
|
|
<div class="share-buttons">
|
|
<a href="#" title="Share on Twitter"><i data-feather="twitter"></i></a>
|
|
<a href="#" title="Share on Facebook"><i data-feather="facebook"></i></a>
|
|
<a href="#" title="Share on LinkedIn"><i data-feather="linkedin"></i></a>
|
|
</div>
|
|
</div>
|
|
</article>
|
|
<div class="text-center mt-5">
|
|
<a href="blog.php" class="btn btn-outline-primary btn-lg"><i data-feather="arrow-left" class="align-middle"></i> Back to Blog</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<footer class="text-center">
|
|
<div class="container">
|
|
<div class="mb-3">
|
|
<a href="#" class="text-white mx-2"><i data-feather="twitter"></i></a>
|
|
<a href="#" class="text-white mx-2"><i data-feather="linkedin"></i></a>
|
|
<a href="#" class="text-white mx-2"><i data-feather="github"></i></a>
|
|
</div>
|
|
<p>© <?php echo date("Y"); ?> Your Name. All Rights Reserved. | <a href="privacy.php">Privacy Policy</a></p>
|
|
</div>
|
|
</footer>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
|
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
|
<script>
|
|
feather.replace();
|
|
</script>
|
|
</body>
|
|
</html>
|