2015-12-03 111 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

相關問題