Skip to content

Commit 29aafe0

Browse files
committed
Add rss
1 parent 3452d6c commit 29aafe0

4 files changed

Lines changed: 43 additions & 24 deletions

File tree

‎_layouts/default.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<meta name="viewport" content="width=device-width">
88
<link rel="alternate" type="application/atom+xml" title="{{ page.title }}" href="https://ruby-korea.github.io/feed.xml" />
99
<link rel="stylesheet" type="text/css" media="screen" href="stylesheets/stylesheet.css">
10+
<link href="feed.xml" type="application/atom+xml" rel="alternate" title="{{ page.title }}" />
1011
<title>{{ page.title }}</title>
1112
</head>
1213
<body>

‎_plugins/generators.rb‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ class RSSGenerator < Generator
33
def generate(site)
44
@index_page = site.pages.find { |page| page.name == "index.md" }
55
@feed_page = site.pages.find { |page| page.name == "feed.xml" }
6+
@rss_page = site.pages.find { |page| page.name == "rss.xml" }
67
@feed_page.data['articles'] = articles
8+
@rss_page.data['articles'] = articles
79
end
810

911
private

‎feed.xml‎

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
---
2+
layout: nil
23
---
34
<?xml version="1.0" encoding="UTF-8"?>
4-
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
5-
<channel>
6-
<title>{{ site.name | xml_escape }}</title>
7-
<description>{% if site.description %}{{ site.description | xml_escape }}{% endif %}</description>
8-
<link>{{ site.url }}</link>
9-
<atom:link href="{{ site.url }}/feed.xml" rel="self" type="application/rss+xml"/>
10-
{% for article in page.articles limit:10 %}
11-
<item>
12-
<title>{{ article.title | xml_escape }}</title>
13-
<dc:creator>{{ article.author | xml_escape }}</dc:creator>
14-
{% if article.excerpt %}
15-
<description>{{ article.excerpt | xml_escape }}</description>
16-
{% elsif article.content %}
17-
<description>{{ article.content | xml_escape }}</description>
18-
{% else %}
19-
<description></description>
20-
{% endif %}
21-
<pubDate>{{ article.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
22-
<link>{{ article.url }}</link>
23-
<guid isPermaLink="true">{{ article.url }}</guid>
24-
</item>
25-
{% endfor %}
26-
</channel>
27-
</rss>
5+
<feed xmlns="http://www.w3.org/2005/Atom">
6+
<title>{{ site.name | xml_escape }}</title>
7+
<description>{% if site.description %}{{ site.description | xml_escape }}{% endif %}</description>
8+
<link href="{{ site.url }}" />
9+
<link href="{{ site.url }}/feed.xml" rel="self" />
10+
<updated>{{ site.time | date: "%a, %d %b %Y %H:%M:%S %z" }}</updated>
11+
{% for article in page.articles limit:10 %}
12+
<entry>
13+
<title>{{ article.title | xml_escape }}</title>
14+
<link href="{{ article.url }}" />
15+
<id>{{ article.url }}</id>
16+
<author>
17+
<name>{{ article.author | xml_escape }}</name>
18+
</author>
19+
<updated>{{ article.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</updated>
20+
</entry>
21+
{% endfor %}
22+
</feed>

‎rss.xml‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
layout: nil
3+
---
4+
<?xml version="1.0" encoding="UTF-8"?>
5+
<rss version="2.0">
6+
<channel>
7+
<title><![CDATA[{{ site.name }}]]></title>
8+
<link>{{ site.url }}</link>
9+
<lastBuildDate>{{ site.time | date: "%a, %d %b %Y %H:%M:%S %z" }}</lastBuildDate>
10+
<language>ko</language>
11+
<description><![CDATA[{{ site.description }}]]></description>
12+
{% for article in page.articles limit:10 %}
13+
<item>
14+
<title><![CDATA[{{ article.title }}]]></title>
15+
<guid isPermaLink="false">{{ article.url }}</guid>
16+
<link>{{ article.url }}</link>
17+
<pubDate>{{ article.date | date: "%a, %d %b %Y %H:%M:%S" }} GMT</pubDate>
18+
</item>
19+
{% endfor %}
20+
</channel>
21+
</rss>

0 commit comments

Comments
 (0)