diff --git a/public/feed.php b/public/feed.php index 1c63f97..ba4b904 100644 --- a/public/feed.php +++ b/public/feed.php @@ -12,14 +12,21 @@ require_once BASE_PATH . '/src/ArticleManager.php'; const FEED_PAGE_SIZE = 20; -$articles = new ArticleManager(BASE_PATH . '/data'); +$articles = new ArticleManager(BASE_PATH . '/data'); +$privateCats = $articles->getPrivateCategories(); $now = time(); $base = rtrim(APP_URL, '/'); $all = array_values(array_filter( $articles->getAll(publishedOnly: true), - static fn (array $a): bool => strtotime((string)($a['published_at'] ?? '')) <= $now + static function (array $a) use ($now, $privateCats): bool { + if (strtotime((string)($a['published_at'] ?? '')) > $now) { + return false; + } + $cat = trim($a['category'] ?? ''); + return $cat === '' || !in_array($cat, $privateCats, true); + } )); // ─── Détection navigateur ──────────────────────────────────────────────────── @@ -95,6 +102,9 @@ if ($isBrowser) { } // ─── Flux XML pour les lecteurs RSS ───────────────────────────────────────── +require_once BASE_PATH . '/src/Parsedown.php'; +$Parsedown = new Parsedown(); + $total = count($all); $lastPage = max(1, (int)ceil($total / FEED_PAGE_SIZE)); $page = max(1, min($lastPage, (int)($_GET['page'] ?? 1))); @@ -150,7 +160,8 @@ echo '' . "\n"; $pubDate = date(DATE_RSS, (int)strtotime((string)($article['published_at'] ?? $article['created_at'] ?? ''))); $link = $base . '/post/' . rawurlencode($article['slug'] ?? ''); $title = htmlspecialchars($article['title'] ?? '', ENT_XML1); - $desc = htmlspecialchars(mb_strimwidth(strip_tags($article['content'] ?? ''), 0, 300, '…'), ENT_XML1); + $plain = preg_replace('/\s+/', ' ', strip_tags($Parsedown->text($article['content'] ?? ''))); + $desc = htmlspecialchars(mb_strimwidth(trim((string)$plain), 0, 300, '…'), ENT_XML1); $guid = htmlspecialchars($base . '/post/' . rawurlencode($article['slug'] ?? ''), ENT_XML1); ?>