Skip to content

Commit f0ccb2f

Browse files
authored
Icon and logo support with simple tests (#412)
Merge pull request 412
1 parent f321e1c commit f0ccb2f

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ The plugin will automatically use any of the following configuration variables,
3333
* `description` - A longer description of what your site is about, e.g., "Where I blog about Jekyll and other awesome things"
3434
* `url` - The URL to your site, e.g., `https://example.com`. If none is provided, the plugin will try to use `site.github.url`.
3535
* `author` - Global author information (see below)
36+
* `feed.icon` - Icon with 1:1 proportions for readers to use for the blog feed (not supported by all readers; often overridden by a favicon or site icon)
37+
* `feed.logo` - Logo with 2:1 proportions for readers to use for the blog feed (not supported by all readers).
38+
For example, both of the preceding can be expressed:
39+
```yml
40+
feed:
41+
icon: /images/icon.png
42+
logo: /images/logo.png
43+
```
44+
3645

3746
### Already have a feed path?
3847

lib/jekyll-feed/feed.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@
2727
<subtitle>{{ site.description | xml_escape }}</subtitle>
2828
{% endif %}
2929

30+
{% if site.feed.icon %}
31+
{% assign feed_icon = site.feed.icon %}
32+
{% unless feed_icon contains "://" %}
33+
{% assign feed_icon = feed_icon | absolute_url %}
34+
{% endunless %}
35+
<icon>{{ feed_icon | xml_escape }}</icon>
36+
{% endif %}
37+
38+
{% if site.feed.logo %}
39+
{% assign feed_logo = site.feed.logo %}
40+
{% unless feed_logo contains "://" %}
41+
{% assign feed_logo = feed_logo | absolute_url %}
42+
{% endunless %}
43+
<logo>{{ feed_logo | xml_escape }}</logo>
44+
{% endif %}
45+
3046
{% if site.author %}
3147
<author>
3248
<name>{{ site.author.name | default: site.author | xml_escape }}</name>

spec/jekyll-feed_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@
125125
expect(feed.encoding).to eql("UTF-8")
126126
expect(feed.lang).to be_nil
127127
expect(feed.valid?).to eql(true)
128+
expect(feed.icon).to be_nil
129+
expect(feed.logo).to be_nil
128130
end
129131

130132
it "outputs the link" do
@@ -238,6 +240,24 @@ def to_s
238240
expect(feed.title.content).to eql(site_title.encode(xml: :text))
239241
end
240242
end
243+
244+
context "with site.icon set" do
245+
let(:site_icon) { "myicon.png" }
246+
let(:overrides) { { "feed" => { "icon" => site_icon } } }
247+
248+
it "uses site.icon for the icon" do
249+
expect(feed.icon.content).to eql("http://example.org/" + site_icon)
250+
end
251+
end
252+
253+
context "with site.logo set" do
254+
let(:site_logo) { "mylogo.png" }
255+
let(:overrides) { { "feed" => { "logo" => site_logo } } }
256+
257+
it "uses site.logo for the logo" do
258+
expect(feed.logo.content).to eql("http://example.org/" + site_logo)
259+
end
260+
end
241261
end
242262

243263
context "smartify" do

0 commit comments

Comments
 (0)