Jekyll Loop在第二次迭代时中断

mot*_*dev 3 liquid jekyll

我正在浏览两个产品 - 在帖子视图页面上我拉了一个辅助帖子(在示例中,一个相关的食谱),它在第一个产品页面上解析得很好 - 在第二个产品页面上就是{{ post.content }}不会解析.我可以用它来破解{{ post.content | markdownify }}- 但我想知道为什么它会破裂.这是相关的代码:

{% for post in site.categories.recipe %}
    {% if post.products contains page.title and post.featured %}
        <div class="row">
            <div class="four columns">
            <h4>{{ post.title }}</h4>
            <ul>
                <li>Serves {{ post.serves }}</li>
               <li>Prep: {{ post.time }}</li>
                <li><a href=" ">Share</a></li>
            </ul>

            {{ post.content }}

            ...

            <!-- All tags are closed, the rest just isn't relevant -->

    {% endif %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

小智 14

请用计数器找到我的解决方案

<pre>

{% assign counter=0 %}

{% for post in site.posts%}

 {% if post.category == 'blog' and counter < 2 %}
 {% assign counter=counter | plus:1 %}   

     {{post.content}}

 {% endif %}

{% endfor %}

</pre>
Run Code Online (Sandbox Code Playgroud)