las*_*oob 4 markup liquid jekyll
所以最近的帖子查询了最近5篇帖子.
 {% for post in site.posts limit:5 %}
     <li>
    < a href="{{ post.url }}">{{ post.title }}</a>
     </li>
   {% endfor %}
但是,这也显示了当前的一个,如果它是5个最新帖子之一.我试图包含一个检查URL的if语句,但是如何在限制变量中添加+1?
PS:我在锚标签中包含了一个空格,因此它的代码可读
检查网址应该有效.只需循环六个项目,并在找不到匹配项时隐藏最后一项.
{% for post in site.posts limit:6 %}
  {% if post.url != page.url %} 
    {% if forloop.index < 6 or found %}
      <li>
        <a href="{{ post.url }}">{{ post.title }}</a>
      </li>
    {% endif %}
  {% else %}
    {% assign found = true %} 
  {% endif %}
{% endfor %}
代码的作用(一步一步):
*允许你循环/迭代6号帖
小智 7
更好的选择是使用:
{% assign posts = site.posts | where_exp:"post","post.url != page.url" %}
{% for post in posts limit:5 %}
  <li>
    <a href="{{ post.url }}">{{ post.title }}</a>
  </li>
{% endfor %}
它能做什么:
| 归档时间: | 
 | 
| 查看次数: | 734 次 | 
| 最近记录: |