New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to show all archives? #1553

Closed
giuem opened this Issue Oct 18, 2015 · 5 comments

Comments

4 participants
@giuem
Copy link

giuem commented Oct 18, 2015

Recently,I update hexo to 3.0. But I find my archives can't show ALL and it only show 5 items.

Here is my code.I think the problem is page.posts, it only return 5 items 馃槱

_config.yml

archive: 1
category: 1
tag: 1

per_page: 5
pagination_dir: page

archives.ejs

  <%
  var title = page.title;

  if (is_archive()){
    title = __('title.archives');

    if (is_month()){
      title += ': ' + page.year + '/' + page.month;
    } else if (is_year()){
      title += ': ' + page.year;
    }
  } else if (is_category()){
    title = __('title.category') + ': '  + page.category;
  } else if (is_tag()){
    title = __('title.tag') + ': ' + page.tag;
  }
  %>
  <% var last; %>
  <% page.posts.each(function(post){ %>
    <% var day = date(post.date, 'DD'), month = date(post.date, 'YYYY MMMM') %>
    <% if(!last){ %>
      <%  last = month; %>
      <article class="archives-group">
        <time datetime="<%= date(post.date, 'YYYY-MM') %>" class="archives-data"><%= last %></time>
        <ul class="archives-list">
          <li><a href="<%- url_for(post.path) %>"><%= post.title %></a></li>
    <% } else if (last == month) { %>
      <li><a href="<%- url_for(post.path) %>"><%= post.title %></a></li>
    <% } else { %>
      <%  last = month; %>
        </ul>
      </article>
      <article class="archives-group">
        <time datetime="<%= date(post.date, 'YYYY-MM') %>" class="archives-data"><%= last %></time>
        <ul class="archives-list">
          <li><a href="<%- url_for(post.path) %>"><%= post.title %></a></li>
    <% } %>
  <% }) %>
@vitto

This comment has been minimized.

Copy link

vitto commented Oct 19, 2015

Have you tried to change per_page: 5 to a different number?

@leesei

This comment has been minimized.

Copy link
Member

leesei commented Oct 20, 2015

Will it work if you delete per_page and pagination_dir?
If so it is a bug.

@giuem

This comment has been minimized.

Copy link
Author

giuem commented Oct 20, 2015

@leesei @vitto But I need pagination in home..

@giuem

This comment has been minimized.

Copy link
Author

giuem commented Oct 24, 2015

I just need hexo-generator-archive.

archive_generator:
  per_page: 10
  yearly: true
  monthly: true
@percy507

This comment has been minimized.

Copy link

percy507 commented Sep 28, 2016

@giuem
change this

<% page.posts.each(function(post){ %>

into

<% site.posts.each(function(post){ %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment