From 57c2dd04496f902d887c614f20d172afaabebf59 Mon Sep 17 00:00:00 2001 From: wiwiec <derwiwie@googlemail.com> Date: Sun, 12 Feb 2017 20:03:48 +0100 Subject: [PATCH] respecting content:true correctly; --- atom.xml | 6 +++++- lib/generator.js | 32 +++++++++++++++++--------------- rss2.xml | 6 +++++- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/atom.xml b/atom.xml index bada2c4..e91f0c2 100644 --- a/atom.xml +++ b/atom.xml @@ -30,7 +30,11 @@ {% elif post.excerpt %} {{ post.excerpt }} {% elif post.content %} - {{ post.feedShortContent }} + {% if not config.feed.content and config.feed.content_limit %} + {{ post.feedShortContent }} + {% else %} + {{ post.content }} + {% endif %} {% endif %} </summary> {% for category in post.categories.toArray() %} diff --git a/lib/generator.js b/lib/generator.js index d843a5e..e694bba 100644 --- a/lib/generator.js +++ b/lib/generator.js @@ -23,22 +23,24 @@ module.exports = function(locals) { var posts = locals.posts.sort('-date'); if (feedConfig.limit) posts = posts.limit(feedConfig.limit); - posts.forEach(function(post) { - var safe_content = hexoutil.stripHTML(post.content); - post.feedShortContent = safe_content.substring(0, feedConfig.content_limit); - - if (typeof feedConfig.content_limit_delim != 'undefined') { - var delim_pos = -1; - for (var ind in feedConfig.content_limit_delim) { - var delim = feedConfig.content_limit_delim[ind]; - delim_pos = post.feedShortContent.lastIndexOf(delim); - if (delim_pos > -1) { - post.feedShortContent = post.feedShortContent.substring(0, delim_pos+1); - break; + if (typeof feedConfig.content_limit != 'undefined') { + posts.forEach(function(post) { + var safe_content = hexoutil.stripHTML(post.content); + post.feedShortContent = safe_content.substring(0, feedConfig.content_limit); + + if (typeof feedConfig.content_limit_delim != 'undefined') { + var delim_pos = -1; + for (var ind in feedConfig.content_limit_delim) { + var delim = feedConfig.content_limit_delim[ind]; + delim_pos = post.feedShortContent.lastIndexOf(delim); + if (delim_pos > -1) { + post.feedShortContent = post.feedShortContent.substring(0, delim_pos+1); + break; + } } - } - } - }); + } + }); + } var url = config.url; if (url[url.length - 1] !== '/') url += '/'; diff --git a/rss2.xml b/rss2.xml index a116516..41a2a30 100644 --- a/rss2.xml +++ b/rss2.xml @@ -22,7 +22,11 @@ {% elif post.excerpt %} {{ post.excerpt }} {% elif post.content %} - {{ post.feedShortContent }} + {% if not config.feed.content and config.feed.content_limit %} + {{ post.feedShortContent }} + {% else %} + {{ post.content }} + {% endif %} {% endif %} </description> {% if config.feed.content and post.content %}