【发布时间】:2015-12-03 01:49:51
【问题描述】:
根据 Jekyll 的文档,不支持对集合进行分页。我尝试为我的投资组合集合模仿 Jekyll 帖子文件夹结构,然后应用稍微修改的分页 Liquid 语法来处理投资组合集合,但无济于事。
有没有一种方法/解决方法可以在 Jekyll 网站中为集合设置分页?
【问题讨论】:
标签: github pagination jekyll github-pages
根据 Jekyll 的文档,不支持对集合进行分页。我尝试为我的投资组合集合模仿 Jekyll 帖子文件夹结构,然后应用稍微修改的分页 Liquid 语法来处理投资组合集合,但无济于事。
有没有一种方法/解决方法可以在 Jekyll 网站中为集合设置分页?
【问题讨论】:
标签: github pagination jekyll github-pages
有一种方法可以将 prev 和 next 标签分配给您的收藏的“假”分页。以下是 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
【讨论】:
jekyll-paginate 仅对帖子进行分页。
如果要对集合进行分页,可以使用Octopress Paginate,但 github 不支持 (for now)。
【讨论】: