forked from hexojs/hexo-generator-feed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rss2.xml
63 lines (63 loc) · 2.64 KB
/
rss2.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>{{ config.title }}</title>
<link>{{ url }}</link>
{% if icon %}
<image>
<url>{{ icon }}</url>
<title>{{ config.title }}</title>
<link>{{ url }}</link>
</image>
{% endif %}
<atom:link href="{{ feed_url | uriencode }}" rel="self" type="application/rss+xml"/>
{% if config.feed.hub %}<atom:link href="{{ config.feed.hub | uriencode }}" rel="hub"/>{% endif %}
<description>{{ config.description }}</description>
<pubDate>{% if posts.first().updated %}{{ posts.first().updated.toDate().toUTCString() }}{% else %}{{ posts.first().date.toDate().toUTCString() }}{% endif %}</pubDate>
<generator>http://hexo.io/</generator>
{% for post in posts.toArray() %}
<item>
<title>{{ post.title }}</title>
<link>{{ post.permalink | uriencode }}</link>
<guid>{{ post.permalink | uriencode }}</guid>
<pubDate>{{ post.date.toDate().toUTCString() }}</pubDate>
{% if post.description %}
<description>{{ post.description }}</description>
{% elif post.intro %}
<description>{{ post.intro }}</description>
{% elif post.excerpt %}
<description>{{ post.excerpt }}</description>
{% elif post.content %}
{% set short_content = post.content.substring(0, config.feed.content_limit) %}
{% if config.feed.content_limit_delim %}
{% set delim_pos = short_content.lastIndexOf(config.feed.content_limit_delim) %}
{% if delim_pos > -1 %}
<description>{{ short_content.substring(0, delim_pos) }}</description>
{% else %}
<description>{{ short_content }}</description>
{% endif %}
{% else %}
<description>{{ short_content }}</description>
{% endif %}
{% endif %}
{% if post.image %}
<enclosure url="{{ url + post.image | uriencode }}" type="image"/>
{% endif %}
{% if config.feed.content and post.content %}
<content:encoded><![CDATA[{{ post.content | noControlChars | safe }}]]></content:encoded>
{% endif %}
{% for category in post.categories.toArray() %}
<category domain="{{ url + category.path | uriencode }}">{{ category.name }}</category>
{% endfor %}
{% for tag in post.tags.toArray() %}
<category domain="{{ url + tag.path | uriencode }}">{{ tag.name }}</category>
{% endfor %}
{% if post.comments %}
<comments>{{ post.permalink | uriencode }}#disqus_thread</comments>
{% endif %}
</item>
{% endfor %}
</channel>
</rss>