Collections 如何在Jekyll中使用捕获周期奇偶和特定于目标的收集项

Collections 如何在Jekyll中使用捕获周期奇偶和特定于目标的收集项,collections,jekyll,capture,Collections,Jekyll,Capture,嗨,我在一个杰基尔网站工作。我使用捕获周期来显示集合的奇数和偶数。我还想特别针对本页上显示的收藏 以下是迄今为止的代码: {% assign sorted = (site.catalog | sort: 'date') | reverse %} {% for project in sorted limit: 5 reversed %} {% capture thecycle %}{% cycle 'odd', 'even' %}{% endcapture %} {% if thecyc

嗨,我在一个杰基尔网站工作。我使用捕获周期来显示集合的奇数和偶数。我还想特别针对本页上显示的收藏

以下是迄今为止的代码:

{% assign sorted = (site.catalog | sort: 'date') | reverse %}
{% for project in sorted limit: 5 reversed %}

{% capture thecycle %}{% cycle 'odd', 'even' %}{% endcapture %}
    {% if thecycle == 'odd' %}
        {% if project.featured == "1" || project.featured == "3" || project.featured == "5" %}
<div>{{ project.title }} {{ project.subtitle }}</div>
{% endif %}

{% if thecycle == 'even' %}
<div>{{ project.title }} {{ project.subtitle }}</div>
{% endif %}
{% endfor %}
{%assign sorted=(site.catalog | sort:'date')| reverse%}
{已排序限制中的项目为%5%}
{%capture thecycle%}{%cycle'奇数','偶数'}{%endcapture%}
{%如果循环=='奇数'%}
{%if project.featured==“1”| | project.featured==“3”| | project.featured==“5”}
{{project.title}{{project.subtitle}}
{%endif%}
{%如果循环=='偶数'%}
{{project.title}{{project.subtitle}}
{%endif%}
{%endfor%}
所以我想在这页上总共显示五个项目。对于奇数周期,我希望这些项(1,3,5)显示某种格式,对于偶数周期,我希望这些项(2,4)显示某种格式

我开始使用的方法将在集合项的前面显示此变量:

特色:“1”


提前感谢您的帮助

这有帮助吗@ApproxiValue它确实有所帮助,我有更多的信息,现在我正在弄清楚如何在捕获中专门放置奇数和偶数的每个集合项目。我还没有完全弄明白答案。以下是对我有效的方法:
{%assign features=site.catalog | where:“featured”,“yes”| sort:“featured rank”}{%for project in features limit:5%}
--然后基本上只需在每个集合的前端添加“featured”作为变量,然后分类处理剩下的。很好。你应该这样做。这有用吗@ApproxiValue它确实有所帮助,我有更多的信息,现在我正在弄清楚如何在捕获中专门放置奇数和偶数的每个集合项目。我还没有完全弄明白答案。以下是对我有效的方法:
{%assign features=site.catalog | where:“featured”,“yes”| sort:“featured rank”}{%for project in features limit:5%}
--然后基本上只需在每个集合的前端添加“featured”作为变量,然后分类处理剩下的。很好。你应该。