$slug, 'title' => $meta['title'] ?? $slug, 'date' => $meta['date'] ?? date('Y-m-d', filemtime($file)), 'body' => $body, ]; } function all_posts(): array { $posts = []; foreach (glob(POSTS_DIR . '/*.md') ?: [] as $file) { if ($p = load_post(basename($file, '.md'))) { $posts[] = $p; } } usort($posts, fn($a, $b) => strcmp($b['date'], $a['date'])); return $posts; } function render_markdown(string $md): string { static $pd = null; if ($pd === null) { $pd = new Parsedown(); $pd->setSafeMode(true); } return $pd->text($md); } function post_date_display(string $date): string { $ts = strtotime($date); return $ts ? date('m/d/Y', $ts) : htmlspecialchars($date); } function render_post_list(array $posts): void { if (!$posts) { echo '
no posts yet.
'; return; } echo '