Skip to content

Commit

Permalink
add order-by option
Browse files Browse the repository at this point in the history
  • Loading branch information
swwind committed Aug 22, 2018
1 parent 363d606 commit 4662a24
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ feed:
content:
content_limit: 140
content_limit_delim: ' '
order_by: -date
```
- **type** - Feed type. (atom/rss2)
Expand All @@ -39,3 +40,4 @@ feed:
- **content** - (optional) set to 'true' to include the contents of the entire post in the feed.
- **content_limit** - (optional) Default length of post content used in summary. Only used, if **content** setting is false and no custom post description present.
- **content_limit_delim** - (optional) If **content_limit** is used to shorten post contents, only cut at the last occurrence of this delimiter before reaching the character limit. Not used by default.
- **order_by** - Feed order-by. (Default: -date)
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ var config = hexo.config.feed = assign({
hub: '',
content: true,
content_limit: 140,
content_limit_delim: ''
content_limit_delim: '',
order_by: '-date'
}, hexo.config.feed);

var type = config.type.toLowerCase();
Expand Down
2 changes: 1 addition & 1 deletion lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = function(locals) {
var feedConfig = config.feed;
var template = feedConfig.type === 'rss2' ? rss2Tmpl : atomTmpl;

var posts = locals.posts.sort('-date');
var posts = locals.posts.sort(feedConfig.order_by);
posts = posts.filter(function(post) {
return post.draft !== true;
});
Expand Down

0 comments on commit 4662a24

Please sign in to comment.