[英]Jekyll - Liquid Templating - Exclude a Category from Widget
I am attempting to rebuild a sidebar widget which shows my categories used in Jekyll. 我试图重建一个侧栏小部件,该小部件显示我在Jekyll中使用的类别。 It works fine as it is now.
它现在可以正常工作。 I want to change the liquid templating to exclude one specific category link from being shown in this widget.
我想更改液体模板,以使其不显示一个特定类别的链接。
{% assign cat_list = site.categories %}
{% if cat_list.first[0] == null %}
{% for category in cat_list %}
<li><a href="{{ site.baseurl }}/categories#{{ category }}">{{ category }} <span class="cat-count">{{ cat_list[category].size }}</span></a></li>
{% endfor %}
{% else %}
{% for category in cat_list %}
<li><a href="{{ site.baseurl }}/categories#{{ category[0] }}">{{ category[0] }} <span class="cat-count">{{ category[1].size }}</span></a></li>
{% endfor %}
{% endif %}
{% assign cat_list = nil %}
I think what I want is something like 我想我想要的是
{% for category in cat_list **UNLESS category = 'CATEGORY'** %}
But that did not work. 但这没有用。 I'm kinda stuck, is this possible?
我有点卡住,这可能吗?
Thank You. 谢谢。
Not displayed categories array : 未显示类别数组:
{% assign noDisplay = "one,two,three" | split: "," %}
{% assign noDisplay = "one,two,three" | split: "," %}
=> ["one", "two", "three"] {% assign noDisplay = "one,two,three" | split: "," %}
=> [“一个”,“两个”,“三个”]
The test : 考试 :
{% unless noDisplay contains category[0] %}
{{ category[0] }}...
{% endunless %}
Thank you, @David Jacquel 谢谢@David Jacquel
{% assign noDisplay = "CATEGORY" | split: "," %}
{% assign cat_list = site.categories %}
{% if cat_list.first[0] == null %}
{% for category in cat_list %}
<li><a href="{{ site.baseurl }}/categories#{{ category }}">{{ category }} <span class="cat-count">{{ cat_list[category].size }}</span></a></li>
{% endfor %}
{% else %}
{% for category in cat_list %}
{% unless noDisplay contains category[0] %}
<li><a href="{{ site.baseurl }}/categories#{{ category[0] }}">{{ category[0] }} <span class="cat-count">{{ category[1].size }}</span></a></li>
{% endunless %}
{% endfor %}
{% endif %}
{% assign cat_list = nil %}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.