0

检查了我能想到的我可能错过的任何可能性,但仍然无法使分页正常工作。如果有人可以提供帮助,将不胜感激。

  • 红宝石版本是ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
  • Jekyll 版本是jekyll 3.4.3
  • gems: [jekyll-paginate]被添加在_config.yml
  • {%for article in paginator.posts%}在代码中使用

输出gem list

*** LOCAL GEMS ***

addressable (2.5.1)
bigdecimal (default: 1.3.0)
coffee-script (2.4.1)
coffee-script-source (1.11.1)
colorator (1.1.0)
did_you_mean (1.1.0)
execjs (2.7.0)
ffi (1.9.18)
forwardable-extended (2.6.0)
io-console (default: 0.4.6)
jekyll (3.4.3)
jekyll-coffeescript (1.0.2)
jekyll-paginate (1.1.0)
jekyll-paginate-category (0.1.2)
jekyll-sass-converter (1.5.0)
jekyll-watch (1.5.0)
json (default: 2.0.2)
kramdown (1.13.2)
liquid (3.0.6)
listen (3.0.8)
mercenary (0.3.6)
minitest (5.10.1)
net-telnet (0.1.1)
openssl (default: 2.0.3)
pathutil (0.14.0)
power_assert (0.4.1)
psych (default: 2.2.2)
public_suffix (2.0.5)
rake (12.0.0)
rb-fsevent (0.9.8)
rb-inotify (0.9.8)
rdoc (default: 5.0.0)
rouge (1.11.1)
safe_yaml (1.0.4)
sass (3.4.23)
test-unit (3.2.3)
xmlrpc (0.2.1)
4

1 回答 1

0

试试看:

1-制作安装分页命令

sudo gem install jekyll-paginate

2-配置_config.yml:

添加插件jekyll-paginate

添加变量paginate: 5paginate_path: "/blog/page:num/"

在索引页中插入代码:

<!-- This loops through the paginated posts -->
{% for post in paginator.posts %}
  <h1><a href="{{ post.url }}">{{ post.title }}</a></h1>
  <p class="author">
    <span class="date">{{ post.date }}</span>
  </p>
  <div class="content">
    {{ post.content }}
  </div>
{% endfor %}

<!-- Pagination links -->
<div class="pagination">
  {% if paginator.previous_page %}
    <a href="{{ paginator.previous_page_path }}" class="previous">Previous</a>
  {% else %}
    <span class="previous">Previous</span>
  {% endif %}
  <span class="page_number ">Page: {{ paginator.page }} of {{ paginator.total_pages }}</span>
  {% if paginator.next_page %}
    <a href="{{ paginator.next_page_path }}" class="next">Next</a>
  {% else %}
    <span class="next ">Next</span>
  {% endif %}
</div>
于 2017-10-09T16:37:03.643 回答