diff options
Diffstat (limited to 'blog/blog.php')
| -rw-r--r-- | blog/blog.php | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/blog/blog.php b/blog/blog.php deleted file mode 100644 index f944c2e..0000000 --- a/blog/blog.php +++ /dev/null @@ -1,109 +0,0 @@ -<?php -require 'Parsedown.php'; -$Parsedown = new Parsedown(); - -$postsDir = __DIR__ . '/posts/'; - -// Get requested post from URL (pretty slug) -$postParam = $_GET['post'] ?? null; - -if ($postParam) { - // Search for matching file by slug (ignoring date prefix) - $files = glob($postsDir . '*.md'); - $found = null; - foreach ($files as $file) { - $filename = pathinfo($file, PATHINFO_FILENAME); // e.g., 2026-03-05-why-i-use-nixos - $slug = preg_replace('/^\d{4}-\d{2}-\d{2}-/', '', $filename); // remove date prefix - if ($slug === $postParam) { - $found = $file; - break; - } - } - - if ($found) { - $markdown = file_get_contents($found); - - // Extract first heading line (# Title) as title - if (preg_match('/^# (.+)/m', $markdown, $matches)) { - $title = trim($matches[1]); - // Remove the first heading from content - $markdown = preg_replace('/^# .*/', '', $markdown, 1); - } else { - $title = "Blog Post"; - } - - $content = $Parsedown->text($markdown); - } else { - // Fallback to list if slug not found - $postParam = null; - } -} - -// If no valid post requested → show list of all posts -if (!$postParam) { - $files = array_reverse(glob($postsDir . '*.md')); // newest first - $content = "<ul class='blog-list'>"; - foreach ($files as $file) { - $filename = pathinfo($file, PATHINFO_FILENAME); - $slug = preg_replace('/^\d{4}-\d{2}-\d{2}-/', '', $filename); - - // Extract first # heading as title - $mdContent = file_get_contents($file); - if (preg_match('/^# (.+)/m', $mdContent, $matches)) { - $name = htmlspecialchars(trim($matches[1])); - } else { - $name = htmlspecialchars($slug); - } - - $content .= "<li><a href='/blog/$slug'>$name</a></li>"; - } - $content .= "</ul>"; - $title = "Blog"; -} -?> - -<!DOCTYPE html> -<html lang="en"> -<head> -<meta charset="UTF-8"> -<title><?= htmlspecialchars($title) ?></title> -<link rel="stylesheet" href="../style.css"> -<style> -/* Blog-specific tweaks */ -.blog-content { - margin-top: 20px; - line-height: 1.6; -} -.blog-content h1, .blog-content h2, .blog-content h3 { - color: #ff00ff; - text-shadow: 0 0 5px #ff00ff, 0 0 15px rgba(255,0,255,0.6); -} -.blog-content p, .blog-content li { - color: #e0d6ff; -} -.blog-list li { - margin-bottom: 8px; -} -.blog-list a { - color: #00ffff; - text-decoration: none; -} -.blog-list a:hover { - text-shadow: 0 0 8px #00ffff; -} -</style> -</head> -<body> -<canvas id="bg"></canvas> -<div class="container"> - <h1><?= htmlspecialchars($title) ?></h1> - <div class="blog-content"> - <?= $content ?> - </div> - <footer> - <p>© 256phi | 2026 | <a href="/home">Home</a></p> - </footer> -</div> -<script type="module" src="../main.js"></script> -</body> -</html> |
