【问题标题】:Jekyll Paginate is not workingJekyll Paginate 不工作
【发布时间】:2017-04-19 07:32:02
【问题描述】:

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

  • Ruby 版本为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)

【问题讨论】:

标签: rubygems jekyll jekyll-paginator


【解决方案1】:

试试看:

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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-29
    • 2016-08-31
    • 2016-03-07
    • 2012-01-28
    • 1970-01-01
    • 2018-03-10
    相关资源
    最近更新 更多