在 Jekyll 索引页面中使用 {{ content }} 和生成器

Using {{ content }} and generators in Jekyll index pages

在 Jekyll 中,post 在其布局中显示为:

{{ content }}

任何可能对该内容具有 运行 的生成器都显示如下:

{{ content | toc_generate }}

不幸的是,这在索引页上不起作用,因为 {{ content }} 在索引页上不显示任何内容。相反,我们被告知使用 for 循环:

{% for post in site.posts %}
    {{ post.content }}
{% endfor %}

所以,问题:

由于我无法使用 {{ content }},我如何才能在索引页上获得 运行 的生成器?

我最好的猜测...

{% for post in site.posts %}
    {{ post | toc_generator }}
{% endfor %}

...什么都不做。

有什么帮助吗?

试试这个:

{% capture content %}
    {% for post in site.posts %}
        <h2>{{ post.tile }}</h2>
        {{ post.content }}
    {% endfor %}
{% endcapture %}
{{ content | toc_generator }}
{{ content }}