Skip to content

Commit 8514dd4

Browse files
committed
fix: as readme promises, use id from a post's front matter if present
1 parent f958a9a commit 8514dd4

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
...
66

7-
## 3.1.1 / 2024/02-02
7+
## 3.1.2 / 2024-03-02
8+
9+
* Fix: as readme promises, use `id` from a post's front matter if present
10+
11+
## 3.1.1 / 2024-02-02
812

913
* Remove duplicate variable assignment (@jbennett)
1014

lib/bridgetown-feed/feed.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@
4646
{% endif %}
4747
{% assign post_limit = site.feed.collections[page.collection].post_limit | default: site.feed.post_limit | default: 10 %}
4848
{% for post in posts limit: post_limit %}
49+
{% assign post_id = post.data.id | default: post.id %}
4950
<entry{% if post.lang %}{{" "}}xml:lang="{{ post.lang }}"{% endif %}>
5051
<title type="html">{{ post.title | smartify | strip_html | normalize_whitespace | xml_escape }}</title>
5152
<link href="{{ post.absolute_url | default: post.url | absolute_url }}" rel="alternate" type="text/html" title="{{ post.title | xml_escape }}" />
5253
<published>{{ post.date | date_to_xmlschema }}</published>
5354
<updated>{{ post.last_modified_at | default: post.date | date_to_xmlschema }}</updated>
54-
<id>{{ post.id | absolute_url | xml_escape }}</id>
55+
<id>{{ post_id | absolute_url | xml_escape }}</id>
5556
{% assign excerpt_only = post.feed.excerpt_only | default: site.feed.excerpt_only %}
5657
{% unless excerpt_only %}
5758
<content type="html" xml:base="{{ post.absolute_url | default: post.url | absolute_url | xml_escape }}">{{ post.content | strip | xml_escape }}</content>

lib/bridgetown-feed/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module Bridgetown
44
module Feed
5-
VERSION = "3.1.1"
5+
VERSION = "3.1.2"
66
end
77
end

spec/bridgetown-feed_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@
169169
expect(post.summary).to be_nil
170170
end
171171

172+
it "has the correct item ids" do
173+
expect(feed.items.first.id.content).to eql("repo://posts.collection/_posts/2016-04-25-author-reference.md")
174+
expect(feed.items.last.id.content).to eql("https://example.com/foo")
175+
end
176+
172177
context "with site.lang set" do
173178
lang = "en_US"
174179
let(:overrides) { { "lang" => lang } }

spec/fixtures/src/_posts/2013-12-12-dec-the-second.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
id: https://example.com/foo
23
excerpt: "Foo"
34
image: "/image.png"
45
category: news

0 commit comments

Comments
 (0)