如何使用 pelican-bootstrap3 添加第二个标签列表

How to add a second tag list using pelican-bootstrap3

我想像标签一样列出我用来构建模型的乐高套装,但在一个单独的列表中。根据鹈鹕文档,这应该是可能的。但是当我 运行 pelican content 我得到

Tags Animal / Duplo / MOC
Sets 1 / 0 / 5 / 7 / 1

而不是

Tags Animal / Duplo / MOC
Sets 10571

我修改了 Daan Debie 的 pelican-bootstrap theme,将 {% include 'includes/setlist.html' %} 添加到 article_info.html

这是我的 setlist.html 文件的样子:

{% if article.sets %}
<span class="label label-default">Sets</span>
{% for set in article.sets %}
    <a href="{{ SITEURL }}/{{ set.url }}">{{ set }}</a>
    {% if not loop.last %}
        /
    {% endif %}
{% endfor %}
{% endif %}

这是我的降价文件的样子:

Title: Girafe
Date: 2015-11-29 14:22:20
Modified: 2015-11-29 14:22:27
Category:
Tags: Animal, Duplo, MOC
Sets: 10571
Slug: girafe
Authors: Yann Baumgartner

![Girafe][girafe]
[girafe]: {filename}/images/girafe.jpg "Girafe"

我通读了有关 Whosebug 的所有鹈鹕问题,但找不到答案。我尝试了以下方法:

我是否遗漏了什么(模板文件、jinja2 过滤器)?任何提示将不胜感激。

pelican 不处理任何非标准元数据。它将保留为字符串。因此,article.sets 将是一个包含 "10571" 的字符串。如果你遍历它,你会得到单独的字符。您需要通过插件或在您的模板中自己处理它,例如:

{% if article.sets %}
<span class="label label-default">Sets</span>
{% for set in article.sets.split(',') %}
    {{ set|trim }}
    {% if not loop.last %}
        /
    {% endif %}
{% endfor %}
{% endif %}

PS:此外,我不确定您期望 set.url 是什么。同样,由于 pelican 不会对您的自定义元数据做任何特殊处理,因此它将是基本字符串,并且不会有 url.