按类别分类的 RSS 提要

RSS feed by category

这是我的 jekyll-botstrap 实例

使用的 atom.xml

标题:Atom Feed


<?xml version="1.0" encoding="{{ site.charset }}"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>{{ site.title }}</title>
    <link href="{{ site.production_url }}/atom.xml" rel="self" />
    <link href="{{ site.production_url }}" />
    <updated>{{ site.time | date_to_xmlschema }}</updated>
    <id>{{ site.production_url }}</id>
    <author>
        <name>{{ site.author.name }}</name>
        <email>{{ site.author.email }}</email>
    </author>
    {% for post in site.posts %}
    <entry>
        <title>{{ post.title }}</title>
        <link href="{{ site.production_url }}{{ post.url }}"/>
        <updated>{{ post.date | date_to_xmlschema }}</updated>
        <id>{{ site.production_url }}{{ post.id }}</id>
        <content type="html">{{ post.content | xml_escape }}</content>
    </entry>
    {% endfor %}
</feed>

请帮我为特殊类别或标签创建原子提要?

您只需要在 for 语句之后添加一些逻辑,如下所示:

{% for post in site.posts %}
{% if post.categories contains 'categoryNameHere' %}
<entry>
        <title>{{ post.title }}</title>
        <link href="{{ site.production_url }}{{ post.url }}"/>
        <updated>{{ post.date | date_to_xmlschema }}</updated>
        <id>{{ site.production_url }}{{ post.id }}</id>
        <content type="html">{{ post.content | xml_escape }}</content>
    </entry>
{% endif %}
{% endfor %}

如果您希望人们能够获得不同的特定 rss,您可以创建不同的端点,例如 /categoryFeed.xml/atomFeed.xml