Skip to content

Node.js based forum software built for the modern web

closed #271

Julian Lama53e75aeaa98
diff --git a/src/feed.js b/src/feed.js
index ded1274e98..59910c7ec0 100644
--- a/src/feed.js
+++ b/src/feed.js
@@ -37,12 +37,14 @@
site_url: nconf.get('url') + 'topic/' + topicData.slug,
image_url: topicData.main_posts[0].picture,
author: topicData.main_posts[0].username,
- pubDate: new Date(parseInt(topicData.main_posts[0].timestamp, 10)).toUTCString(),
ttl: Feed.defaults.ttl
}),
topic_posts = topicData.main_posts.concat(topicData.posts),
title, postData, dateStamp;
+ // Add pubDate if topic contains posts
+ if (topicData.main_posts.length > 0) feed.pubDate = new Date(parseInt(topicData.main_posts[0].timestamp, 10)).toUTCString();
+
for (var i = 0, ii = topic_posts.length; i < ii; i++) {
postData = topic_posts[i];
dateStamp = new Date(parseInt(postData.edited === '0' ? postData.timestamp : postData.edited, 10)).toUTCString();
@@ -74,12 +76,14 @@
description: categoryData.category_description,
feed_url: Feed.defaults.baseUrl + '/categories/' + cid + '.rss',
site_url: nconf.get('url') + 'category/' + categoryData.category_id,
- pubDate: new Date(parseInt(categoryData.topics[0].lastposttime, 10)).toUTCString(),
ttl: Feed.defaults.ttl
}),
topics = categoryData.topics,
title, topicData, dateStamp;
+ // Add pubDate if category has topics
+ if (categoryData.topics.length > 0) feed.pubDate = new Date(parseInt(categoryData.topics[0].lastposttime, 10)).toUTCString();
+
for (var i = 0, ii = topics.length; i < ii; i++) {
topicData = topics[i];
dateStamp = new Date(parseInt(topicData.lastposttime, 10)).toUTCString();