Add author and timestamp uniqueness to feed XML output

This commit is contained in:
Ruben 2026-02-06 18:56:16 +01:00
parent f1447049e4
commit 67e6f1269a

View file

@ -103,10 +103,16 @@ if (str_ends_with($ctx->requestPath, 'feed.xml')) {
echo ' <link href="' . htmlspecialchars($feedUrl) . '" rel="self"/>' . "\n";
echo ' <id>' . htmlspecialchars($listUrl) . '</id>' . "\n";
echo ' <updated>' . $updated . 'T00:00:00Z</updated>' . "\n";
$feedAuthor = $metadata['author'] ?? $feedTitle;
echo ' <author><name>' . htmlspecialchars($feedAuthor) . '</name></author>' . "\n";
$dateCounts = [];
foreach ($items as $item) {
$absoluteUrl = $baseUrl . $item['url'];
$itemDate = ($item['rawDate'] ?? date('Y-m-d')) . 'T00:00:00Z';
$rawDate = $item['rawDate'] ?? date('Y-m-d');
$dateIndex = $dateCounts[$rawDate] ?? 0;
$dateCounts[$rawDate] = $dateIndex + 1;
$itemDate = $rawDate . 'T00:00:' . sprintf('%02d', $dateIndex) . 'Z';
echo ' <entry>' . "\n";
echo ' <title>' . htmlspecialchars($item['title']) . '</title>' . "\n";