Skip to content

Commit

Permalink
Add placeholder for rss if no rss item
Browse files Browse the repository at this point in the history
  • Loading branch information
Izumiko committed Nov 1, 2024
1 parent 886cfc9 commit 63a99c0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions server/rss.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,27 @@ const route = async (req, res) => {
break;
}
}
// if items is empty, add placeholder to keep rss valid
if (!items.length) items.push({
title: ["Placeholder"],
pubDate: [new Date().toISOString()],
enclosure: [
{
$: {
url: "https://placeholder.com",
type: "application/x-bittorrent",
length: 0,
},
},
],
link: ["https://placeholder.com"],
guid: [
{
$: { isPermaLink: true },
_: "https://placeholder.com",
},
],
});
result.rss.channel[0].item = items;
res.set("Content-Type", "text/xml");
res.send(builder.buildObject(result));
Expand Down

0 comments on commit 63a99c0

Please sign in to comment.