2015-12-03 110 views

回答

1

jekyll-paginate只有分页文章。

如果要分类收集,可以使用Octopress Paginate,但它不受github支持(for now)。

+0

肯定。感谢您的澄清。我遇到了Octopress Paginate,但只要我正在构建一个完全由github页面支持的jekyll站点(没有任何插件依赖项),我希望得到一个纯粹的Liquid语法解决方法,或许可以借助一些js函数或jQuery插件。 –

2

有一种方法可以将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>&lt; {{prevPost.title}}</span> 
     </a> 
     {% endif %} 
     {% if nextPost.url %} 
     <a class="next" href="{{nextPost.url}}"> 
      <span>{{nextPost.title}} &gt;</span> 
     </a> 
     {% endif %} 
    </div> 
</div> 

你可以在这里阅读他的整个后:Get Pagination working in Jekyll Collection in Github pages

相关问题