index.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. declare(strict_types=1);
  3. $postsDir = __DIR__ . '/posts/';
  4. $posts = [];
  5. // scan markdown files
  6. foreach (glob($postsDir . '*.md') as $file) {
  7. $filename = basename($file, '.md');
  8. $content = file_get_contents($file);
  9. // extract first markdown H1
  10. if (preg_match('/^#\s+(.+)$/m', $content, $matches)) {
  11. $title = trim($matches[1]);
  12. } else {
  13. $title = $filename;
  14. }
  15. $posts[] = [
  16. 'slug' => $filename,
  17. 'title' => $title,
  18. 'time' => filemtime($file),
  19. ];
  20. }
  21. // sort newest first
  22. usort($posts, fn($a, $b) => $b['time'] <=> $a['time']);
  23. ?>
  24. <!DOCTYPE html>
  25. <html lang="pl">
  26. <head>
  27. <meta charset="UTF-8">
  28. <meta name="viewport" content="width=device-width, initial-scale=1">
  29. <title>Blog</title>
  30. <link rel="stylesheet" href="../style.css">
  31. <script src="https://unpkg.com/cursor-effects@latest/dist/browser.js"></script>
  32. <script>
  33. window.addEventListener("load", (event) => {
  34. new cursoreffects.ghostCursor();
  35. });
  36. </script>
  37. </head>
  38. <body>
  39. <div class="container bio">
  40. <h1>📝 Blog 💻</h1>
  41. <img src="../fish.gif" class="small-pic">
  42. <p class="center">Blog posts:</p>
  43. <?php if (empty($posts)): ?>
  44. <p>Brak wpisów.</p>
  45. <?php else: ?>
  46. <ul class="post-list">
  47. <?php foreach ($posts as $post): ?>
  48. <a class="no-button" href="/blog/blog.php?b=<?= htmlspecialchars($post['slug']) ?>">
  49. <?= htmlspecialchars($post['title']) ?>
  50. </a>
  51. <time datetime="<?= date('c', $post['time']) ?>">
  52. <?= date('Y-m-d', $post['time']) ?>
  53. </time>
  54. <br>
  55. <?php endforeach; ?>
  56. <a class="no-button" href="/blog/video_games.php">
  57. Video Game Ranking </a>
  58. <time datetime="2026-02-10T14:23:27+00:00">
  59. 2026-02-10 </time>
  60. <br>
  61. </ul>
  62. <?php endif; ?>
  63. </div>
  64. </main>
  65. <footer>
  66. <p class="center"><img src="../favicon.ico">(c) computer_glamour</p>
  67. <img src="../buttons/-18.gif" class="footer-button">
  68. <img src="../buttons/xmpp.gif" class="footer-button">
  69. <img src="../buttons/notread.gif" class="footer-button">
  70. <img src="../buttons/right2repair.gif" class="footer-button">
  71. </footer>
  72. </body>
  73. </html>