Skip to content

Commit

Permalink
fix: as readme promises, use id from a post's front matter if present
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredcwhite committed Mar 3, 2024
1 parent f958a9a commit 8514dd4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

...

## 3.1.1 / 2024/02-02
## 3.1.2 / 2024-03-02

* Fix: as readme promises, use `id` from a post's front matter if present

## 3.1.1 / 2024-02-02

* Remove duplicate variable assignment (@jbennett)

Expand Down
3 changes: 2 additions & 1 deletion lib/bridgetown-feed/feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@
{% endif %}
{% assign post_limit = site.feed.collections[page.collection].post_limit | default: site.feed.post_limit | default: 10 %}
{% for post in posts limit: post_limit %}
{% assign post_id = post.data.id | default: post.id %}
<entry{% if post.lang %}{{" "}}xml:lang="{{ post.lang }}"{% endif %}>
<title type="html">{{ post.title | smartify | strip_html | normalize_whitespace | xml_escape }}</title>
<link href="{{ post.absolute_url | default: post.url | absolute_url }}" rel="alternate" type="text/html" title="{{ post.title | xml_escape }}" />
<published>{{ post.date | date_to_xmlschema }}</published>
<updated>{{ post.last_modified_at | default: post.date | date_to_xmlschema }}</updated>
<id>{{ post.id | absolute_url | xml_escape }}</id>
<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.absolute_url | default: post.url | absolute_url | xml_escape }}">{{ post.content | strip | xml_escape }}</content>
Expand Down
2 changes: 1 addition & 1 deletion lib/bridgetown-feed/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Bridgetown
module Feed
VERSION = "3.1.1"
VERSION = "3.1.2"
end
end
5 changes: 5 additions & 0 deletions spec/bridgetown-feed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@
expect(post.summary).to be_nil
end

it "has the correct item ids" do
expect(feed.items.first.id.content).to eql("repo://posts.collection/_posts/2016-04-25-author-reference.md")
expect(feed.items.last.id.content).to eql("https://example.com/foo")
end

context "with site.lang set" do
lang = "en_US"
let(:overrides) { { "lang" => lang } }
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/src/_posts/2013-12-12-dec-the-second.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
id: https://example.com/foo
excerpt: "Foo"
image: "/image.png"
category: news
Expand Down

0 comments on commit 8514dd4

Please sign in to comment.