Skip to content

How to create a pagination #303

Discussion options

You must be logged in to vote

To do that, you need to understand two concepts:

  • Lume only can generate new pages dynamically using pages.tmpl.js
  • The paginate plugin is only a helper to group an array of pages into groups. For example:
    // Let's say we have this array
    const pages = [Post1, Post2, Post3];
    
    // Order in groups of 2
    const pagination = paginate(pages, { size: 2 });
    
    // It returns
    [{
      url: "/page1",
      results: [Post1, Post2],
      pagination: {
        page: 1,
        totalPages: 2,
        totalResults: 3,
        previous: undefined,
        next: "/page2",
      },{
      url: "/page2",
      results: [Post3],
      pagination: {
        page: 2,
        totalPages: 2,
        totalResults: 3,
        previous: "/page1",
        next: undefined,
      },
    }];

The i…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@officialrajdeepsingh
Comment options

@oscarotero
Comment options

Answer selected by officialrajdeepsingh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants