Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ feed:
posts_limit: 20
```

### Posts sort

By default, posts will be sorted by `date` in the feed. Simply define a new sorting method in your config:

```yml
feed:
posts_sort: last_modified_at
```

## Collections

Jekyll Feed can generate feeds for collections other than the Posts collection. This works best for chronological collections (e.g., collections with dates in the filenames). Simply define which collections you'd like feeds for in your config:
Expand Down
10 changes: 8 additions & 2 deletions lib/jekyll-feed/feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,16 @@
{% if page.category %}
{% assign posts = posts | where: "categories", page.category %}
{% endif %}
<!-- combine weeklies to feed -->
{% if page.collection == "posts" %}
{% assign posts = site.posts | concat: site.weeklies %}
{% endif %}

{% unless site.show_drafts %}
{% assign posts = posts | where_exp: "post", "post.draft != true" %}
{% endunless %}
{% assign posts = posts | sort: "date" | reverse %}
{% assign posts_sort = site.feed.posts_sort | default: "date" %}
{% assign posts = posts | sort: posts_sort | reverse %}
{% assign posts_limit = site.feed.posts_limit | default: 10 %}
{% for post in posts limit: posts_limit %}
<entry{% if post.lang %}{{" "}}xml:lang="{{ post.lang }}"{% endif %}>
Expand All @@ -79,7 +85,7 @@
<id>{{ post.id | absolute_url | xml_escape }}</id>
{% assign excerpt_only = post.feed.excerpt_only | default: site.feed.excerpt_only %}
{% unless excerpt_only %}
<content type="html" xml:base="{{ post.url | absolute_url | xml_escape }}"><![CDATA[{{ post.content | strip }}]]></content>
<content type="html"><![CDATA[{{ post.content | strip }}]]></content>
{% endunless %}

{% assign post_author = post.author | default: post.authors[0] | default: site.author %}
Expand Down