Skip to content

Commit

Permalink
Add support for description in front matter (#297)
Browse files Browse the repository at this point in the history
Merge pull request 297
  • Loading branch information
mohd-akram committed Dec 16, 2021
1 parent 09866ca commit 10d86bb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -62,6 +62,8 @@ Additionally, the plugin will use the following values, if present in a post's Y

* `author` - The author of the post, e.g., "Dr. Jekyll". If none is given, feed readers will look to the feed author as defined in `_config.yml`. Like the feed author, this can also be an object or a reference to an author in `_data/authors.yml` (see below).

* `description` - A short description of the post.

### Author information

*TL;DR: In most cases, put `author: [your name]` in the document's front matter, for sites with multiple authors. If you need something more complicated, read on.*
Expand Down
5 changes: 3 additions & 2 deletions lib/jekyll-feed/feed.xml
Expand Up @@ -94,8 +94,9 @@
<category term="{{ tag | xml_escape }}" />
{% endfor %}

{% if post.excerpt and post.excerpt != empty %}
<summary type="html">{{ post.excerpt | strip_html | normalize_whitespace | xml_escape }}</summary>
{% assign post_summary = post.description | default: post.excerpt %}
{% if post_summary and post_summary != empty %}
<summary type="html">{{ post_summary | strip_html | normalize_whitespace | xml_escape }}</summary>
{% endif %}

{% assign post_image = post.image.path | default: post.image %}
Expand Down
2 changes: 2 additions & 0 deletions spec/fixtures/_posts/2014-03-02-march-the-second.md
@@ -1,6 +1,8 @@
---
image: https://cdn.example.org/absolute.png?h=188&w=250
category: news
excerpt: "ignore me"
description: cool post
---

March the second!
5 changes: 5 additions & 0 deletions spec/jekyll-feed_spec.rb
Expand Up @@ -150,6 +150,11 @@
expect(post.summary.content).to eql("Foo")
end

it "includes the item's description" do
post = feed.items[-2]
expect(post.summary.content).to eql("cool post")
end

it "doesn't include the item's excerpt if blank" do
post = feed.items.first
expect(post.summary).to be_nil
Expand Down

0 comments on commit 10d86bb

Please sign in to comment.