index.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. <!--
  52. <time datetime="<?= date('c', $post['time']) ?>">
  53. <?= date('Y-m-d', $post['time']) ?>
  54. </time>
  55. -->
  56. <br>
  57. <?php endforeach; ?>
  58. <a class="no-button" href="/blog/video_games.php">
  59. Video Game Ranking </a>
  60. <!--
  61. <time datetime="2026-02-10T14:23:27+00:00">
  62. 2026-02-10 </time>
  63. -->
  64. <br>
  65. </ul>
  66. <?php endif; ?>
  67. </div>
  68. </main>
  69. <footer>
  70. <p class="center"><img src="../favicon.ico">(c) computer_glamour</p>
  71. <img src="../buttons/-18.gif" class="footer-button">
  72. <img src="../buttons/xmpp.gif" class="footer-button">
  73. <img src="../buttons/notread.gif" class="footer-button">
  74. <img src="../buttons/right2repair.gif" class="footer-button">
  75. </footer>
  76. </body>
  77. </html>