Skip to content

Commit

Permalink
respecting content:true correctly;
Browse files Browse the repository at this point in the history
  • Loading branch information
wiwie committed Feb 12, 2017
1 parent b973425 commit 57c2dd0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
6 changes: 5 additions & 1 deletion atom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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() %}
Expand Down
32 changes: 17 additions & 15 deletions lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 += '/';
Expand Down
6 changes: 5 additions & 1 deletion rss2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down

0 comments on commit 57c2dd0

Please sign in to comment.