根据Jekyll的文档,集合的分页不被支持。我试图模仿我的投资组合集合中的Jekyll帖子文件夹结构,然后应用稍微修改过的分页Liquid语法来处理投资组合集合,但无济于事。有没有办法在Jekyll网站上为Collections设置分页?
有没有一种方法/解决方法,以便在Jekyll站点中为集合设置分页?
根据Jekyll的文档,集合的分页不被支持。我试图模仿我的投资组合集合中的Jekyll帖子文件夹结构,然后应用稍微修改过的分页Liquid语法来处理投资组合集合,但无济于事。有没有办法在Jekyll网站上为Collections设置分页?
有没有一种方法/解决方法,以便在Jekyll站点中为集合设置分页?
jekyll-paginate只有分页文章。
如果要分类收集,可以使用Octopress Paginate,但它不受github支持(for now)。
有一种方法可以将prev标签和下一个标签分配给您的收藏的“假”分页。下面是如何anjesh做到了:
{% for c in site.tripcollection %}
{% if c.title == page.title %}
{% assign thisPost = c %}
{% if forloop.index == 1 %}
{% assign prevflag = 0 %}
{% assign nextflag = 1 %}
{% elsif forloop.index == forloop.length %}
{% assign prevflag = 1 %}
{% assign nextflag = 0 %}
{% else %}
{% assign prevflag = 1 %}
{% assign nextflag = 1 %}
{% endif %}
{% endif %}
{% endfor %}
{% for c in site.tripcollection %}
{% if c.title == page.title %}
{% assign prevflag = 0 %}
{% endif %}
{% if prevflag == 1 %}
{% assign prevPost = c %}
{% assign page.previous = c %}
{% endif %}
{% endfor %}
{% if nextflag == 1 %}
{% for c in site.tripcollection %}
{% if foundPost == 1 %}
{% assign getNext = 1 %}
{% endif %}
{% if c.title == page.title %}
{% assign foundPost = 1 %}
{% endif %}
{% if getNext == 1%}
{% assign nextPost = c %}
{% assign page.next = c %}
{% assign foundPost = 0 %}
{% assign getNext = 0 %}
{% endif %}
{% endfor %}
{% endif %}
<div id="post-nav">
<div >
{% if prevPost.url %}
<a class="prev" href="{{prevPost.url}}">
<span>< {{prevPost.title}}</span>
</a>
{% endif %}
{% if nextPost.url %}
<a class="next" href="{{nextPost.url}}">
<span>{{nextPost.title}} ></span>
</a>
{% endif %}
</div>
</div>
你可以在这里阅读他的整个后:Get Pagination working in Jekyll Collection in Github pages
肯定。感谢您的澄清。我遇到了Octopress Paginate,但只要我正在构建一个完全由github页面支持的jekyll站点(没有任何插件依赖项),我希望得到一个纯粹的Liquid语法解决方法,或许可以借助一些js函数或jQuery插件。 –