diff --git a/index.html b/index.html index 67ac748..671774f 100644 --- a/index.html +++ b/index.html @@ -3,6 +3,7 @@ Hex Studios + diff --git a/posts/feed.php b/posts/feed.php new file mode 100644 index 0000000..6121550 --- /dev/null +++ b/posts/feed.php @@ -0,0 +1,41 @@ +' . "\n"; +?> + + + <?= xmlEscape($siteTitle) ?> + + + en-us + + + + <?= xmlEscape($post['title']) ?> + + + + + + + + + + + \ No newline at end of file diff --git a/posts/list.php b/posts/list.php index 6d5dba8..33e08bd 100644 --- a/posts/list.php +++ b/posts/list.php @@ -1,49 +1,12 @@ $file, - 'title' => $title, - 'type' => $ext, - 'created' => $date ?: $created, - 'date' => date('F j, Y', $date ?: $created), - ]; -} - -usort($posts, fn($a, $b) => $b['created'] - $a['created']); // newest first +$posts = array_map(function ($p) { + unset($p['excerpt']); + return $p; +}, $posts); echo json_encode($posts); \ No newline at end of file diff --git a/posts/posts.php b/posts/posts.php new file mode 100644 index 0000000..a00bac8 --- /dev/null +++ b/posts/posts.php @@ -0,0 +1,68 @@ +*_`~\[\]]/', '', $text); // markdown symbols + $text = preg_replace('/\(.*?\)/', '', $text); // link targets + $text = preg_replace('/\s+/', ' ', $text); // collapse whitespace + $text = trim($text); + if (mb_strlen($text) > $length) { + $text = mb_substr($text, 0, $length) . '…'; + } + return $text; +} + +function getPosts($dir) { + $skip = ['.', '..', 'list.php', 'feed.php', 'posts.php']; + $files = array_diff(scandir($dir), $skip); + + $posts = []; + foreach ($files as $file) { + $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); + if (!in_array($ext, ['html', 'md'])) continue; + + $path = $dir . '/' . $file; + $fallbackTitle = ucwords(str_replace(['-', '_'], ' ', pathinfo($file, PATHINFO_FILENAME))); + $created = filectime($path); + + $meta = []; + $body = ''; + if ($ext === 'md') { + $raw = file_get_contents($path); + [$meta, $body] = parseFrontMatter($raw); + } + + $title = $meta['title'] ?? $fallbackTitle; + $date = isset($meta['date']) ? strtotime($meta['date']) : $created; + $tags = isset($meta['tags']) && trim($meta['tags']) !== '' + ? array_map('trim', explode(',', $meta['tags'])) + : []; + + $posts[] = [ + 'file' => $file, + 'title' => $title, + 'type' => $ext, + 'created' => $date ?: $created, + 'date' => date('F j, Y', $date ?: $created), + 'tags' => $tags, + 'excerpt' => $body ? makeExcerpt($body) : '', + ]; + } + + usort($posts, fn($a, $b) => $b['created'] - $a['created']); // newest first + + return $posts; +} \ No newline at end of file diff --git a/styles/main.css b/styles/main.css index a3ac734..550ff88 100644 --- a/styles/main.css +++ b/styles/main.css @@ -2,7 +2,7 @@ --background-color: #1a1a1a; --foreground-color: #f0f0ea; --soft-color: #8a8a82; - --accent-color: #a5453a; + --accent-color: #197aa7; --rule-color: #333330; --code-bg: #242422; } @@ -11,7 +11,7 @@ --background-color: #f2f0ea; --foreground-color: #1a1a1a; --soft-color: #6b6a63; - --accent-color: #921b0e; + --accent-color: #197aa7; --rule-color: #d8d5cb; --code-bg: #e8e5da; } @@ -60,28 +60,48 @@ hr { border-color: var(--accent-color); } +/* tag filter row */ +#tags-list { + list-style: none; + padding: 0; + display: flex; + flex-wrap: wrap; + gap: 1em; + margin: 0.5em 0 1.5em; +} +.tag-btn { + background: none; + border: none; + color: var(--soft-color); + font-size: 11pt; + font-family: 'Times New Roman', Times, serif; + cursor: pointer; + padding: 0; +} +.tag-btn:hover { + color: var(--accent-color); +} +.tag-btn.active { + color: var(--accent-color); + text-decoration: underline; +} + /* post lists on the main page */ -#posts-section ul, -#sticky-posts-section ul, -#links-section ul { +.custom-list { list-style: none; padding: 0; } -#posts-section li, -#sticky-posts-section li, -#links-section li { + +.custom-list li { margin: 0.5em 0; } - -#posts-section li::before, -#sticky-posts-section li::before, -#links-section li::before { - content: "> "; +.custom-list li::before { + content: "> "; } i.post-link-date { font-style: italic; - color: #6b6b65; + color: var(--soft-color); font-size: 11pt; text-decoration: none; } @@ -89,6 +109,7 @@ i.post-link-date::before { content: " // "; } + /* post.html */ .back-link { display: inline-block;