【问题标题】:Using {{ content }} and generators in Jekyll index pages在 Jekyll 索引页面中使用 {{ content }} 和生成器
【发布时间】:2015-04-09 22:55:08
【问题描述】:

在 Jekyll 中,帖子的布局是这样显示的:

{{ content }}

可能在该内容上运行的任何生成器都会显示如下:

{{ content | toc_generate }}

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

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

那么问题来了:

由于我不能使用{{ content }},如何让生成器在索引页面上运行?

我的最佳猜测......

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

...什么都不做。

有什么帮助吗?

【问题讨论】:

    标签: ruby jekyll liquid


    【解决方案1】:

    试试这个:

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

    【讨论】:

    • 做到了,现在想想就觉得很简单。大卫,我的网络朋友,你最近对我的 Jekyll 问题帮助很大。
    猜你喜欢
    • 2013-10-18
    • 1970-01-01
    • 1970-01-01
    • 2015-06-09
    • 1970-01-01
    • 1970-01-01
    • 2016-01-03
    • 1970-01-01
    • 2018-12-02
    相关资源
    最近更新 更多