rss2.xml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <rss version="2.0"
  3. xmlns:atom="http://www.w3.org/2005/Atom"
  4. xmlns:content="http://purl.org/rss/1.0/modules/content/">
  5. <channel>
  6. <title>{{ config.title }}</title>
  7. <link>{{ url | uriencode }}</link>
  8. <atom:link href="{{ feed_url | uriencode }}" rel="self" type="application/rss+xml"/>
  9. {% if config.feed.hub %}<atom:link href="{{ config.feed.hub | uriencode }}" rel="hub"/>{% endif %}
  10. <description>{{ config.description }}</description>
  11. <pubDate>{{ posts.first().updated.toDate().toUTCString() }}</pubDate>
  12. <generator>http://hexo.io/</generator>
  13. {% for post in posts.toArray() %}
  14. <item>
  15. <title>{{ post.title }}</title>
  16. <link>{{ (url + post.path) | uriencode }}</link>
  17. <guid>{{ (url + post.path) | uriencode }}</guid>
  18. <pubDate>{{ post.date.toDate().toUTCString() }}</pubDate>
  19. <description>
  20. {% if post.description %}
  21. {{ post.description }}
  22. {% elif post.excerpt %}
  23. {{ post.excerpt }}
  24. {% elif post.content %}
  25. {% set short_content = post.content.substring(0, config.feed.content_limit) %}
  26. {% if config.feed.content_limit_delim %}
  27. {% set delim_pos = short_content.lastIndexOf(config.feed.content_limit_delim) %}
  28. {% if delim_pos > -1 %}
  29. {{ short_content.substring(0, delim_pos) }}
  30. {% else %}
  31. {{ short_content }}
  32. {% endif %}
  33. {% else %}
  34. {{ short_content }}
  35. {% endif %}
  36. {% endif %}
  37. </description>
  38. {% if config.feed.content and post.content %}
  39. <content:encoded><![CDATA[{{ post.content | noControlChars | safe }}]]></content:encoded>
  40. {% endif %}
  41. {% if post.comments %}<comments>{{ (url + post.path) | uriencode }}#disqus_thread</comments>{% endif %}
  42. </item>
  43. {% endfor %}
  44. </channel>
  45. </rss>