2017-10-14 33 views
1

我遵循这种方法来安装paginate v2并为一个集合分页,但是我为paginator创建的每个页面都获得了一个额外的“示例集合”顶级页面链接。如何使用jekyll paginate v2避免使用集合的重复页面?

下面是example.md

--- 
layout: page 
title: Example Collection 
permalink: /example/ 
pagination: 
    enabled: true 
--- 

{% for post in paginator.posts %} 
    <h1>{{ post.title }}</h1> 
{% endfor %} 

{% if paginator.total_pages > 1 %} 
<ul> 
    {% if paginator.previous_page %} 
    <li> 
    <a href="{{ paginator.previous_page_path | prepend: site.baseurl }}">Newer</a> 
    </li> 
    {% endif %} 
    {% if paginator.next_page %} 
    <li> 
    <a href="{{ paginator.next_page_path | prepend: site.baseurl }}">Older</a> 
    </li> 
    {% endif %} 
</ul> 
{% endif %} 

这是我加入到我的config.yml现在

# Collections 
collections: 
    examplecol: 
    output: true 
    permalink: /:collection/:path/ 

# Plugin: Pagination (jekyll-paginate-v2) 
pagination: 
    collection : 'examplecol' 
    enabled  : true 
    debug  : false 
    per_page  : 3 
    #permalink : "/page/:num/" 
    title  : ":title - Page :num of :max" 
    limit  : 0 
    sort_field : "date" 
    sort_reverse : true 

,如果有在_examplecol文件夹超过3个文件,我得到example.md的超过1个实例作为我页眉中的页面。

如何在包含所有分页页面的页眉中只有一个示例集合实例?我想我错过了一些愚蠢的东西。

我尝试删除example.md YAML中的永久链接条目,但这样做使得jekyll处理器无法找到examplecol/index.html。

回答

0

我花了很多试验和错误,但我在头上找到了解决方案。

当paginator制作带有一些项目的页面时,该站点将它们视为页面并呈现它们。

因此,该网站找到my_page.title的所有真实回复并创建页面链接。

<div class="trigger"> 
      {% for my_page in site.pages %} 
       {% if my_page.title %} 
       <a class="page-link" href="{{ my_page.url | relative_url }}">{{ my_page.title | escape }}</a> 
       {% endif %} 
      {% endfor %} 
    </div> 

由于分页程序页面AUTOGEN,可以过滤出来:

<div class="trigger"> 
     {% for my_page in site.pages %} 
      {% if my_page.title and my_page.autogen == nil %} 
      <a class="page-link" href="{{ my_page.url | relative_url }}">{{ my_page.title | escape }}</a> 
      {% endif %} 
     {% endfor %} 
</div> 
相关问题