Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 中间人博客分页显示所有文章_Html_Ruby_Pagination_Blogs_Middleman - Fatal编程技术网

Html 中间人博客分页显示所有文章

Html 中间人博客分页显示所有文章,html,ruby,pagination,blogs,middleman,Html,Ruby,Pagination,Blogs,Middleman,我一直在尝试为我的中间人博客激活分页,但出于某种原因,尽管分页本身似乎可以工作(如底部的按钮所示,一直到第三页),所有文章都显示在每个页面上,而不是仅仅显示十篇 config.rb中的节 activate :blog do |blog| blog.name = "en" blog.prefix = "blog" blog.permalink = "/{year}/{month}/{day}/{title}.html" blog.sources = "/posts/:year-:m

我一直在尝试为我的中间人博客激活分页,但出于某种原因,尽管分页本身似乎可以工作(如底部的按钮所示,一直到第三页),所有文章都显示在每个页面上,而不是仅仅显示十篇

config.rb中的节

activate :blog do |blog|
  blog.name = "en"
  blog.prefix = "blog"
  blog.permalink = "/{year}/{month}/{day}/{title}.html"
  blog.sources = "/posts/:year-:month-:day-:title.html"
  blog.layout = "blog_layout"
  blog.tag_template = "tag.html"
  blog.paginate = true
  blog.page_link = "page:num"
  blog.per_page = 10
end
Blog Index.html

---
pageable: true  
blog: en
priority: 1.0
change_frequency: weekly
description: Tbd.
title: Blog
---
<div class="page-content">
  <div class="container">
    <ul class="blog-post-list">
        <% blog.articles.each do |article| %>
        <li>
          <a href="<%= article.url %>">
            <div>
              <img src="<%= article.data.image %>" class="blog-post-list__image" />
            </div>
            <div class="blog-post-list__post-preview">
              <p class="blog-post-list__title"><%= article.title %></p>
              <p><%= article.summary(140, '...') %></p>
              <span><%= article.date.strftime('%B %e, %Y') %></span>
            </div>
          </a>
        </li>
      <% end %>
      <ul class="paginate">
        <% if paginate && num_pages > 1 %>
            <% if prev_page %>
                <p class="previous"><%= link_to 'Previous page', prev_page %></p>
            <% end %>
        <% end %>
        <% if paginate %>
            <% if next_page %>
                <p class="next "><%= link_to 'Next page', next_page %></p>
            <% end %>
        <% end %>
    </ul>
  </ul>
  </div>
</div>
---
可分页:正确
博客:en
优先权:1.0
更改频率:每周
说明:待定。
标题:博客
---
    • 1 %>


任何提示什么可能是这里的问题,这将导致所有的文章显示无论如何将高度赞赏!提前感谢:)

这不是因为您使用blog.articles.each,而是应该使用page_文章吗?
我认为您必须更改blog.articles.each(文章总数),并使用类似于
的方法来获取页面上所需的文章数量

你把这个整理好了吗?