Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for page.description in front matter to become entry <summary> #297

Merged
merged 1 commit into from Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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