1.0.1 • Published 5 years ago

@chavesweb/vuepress-plugin-pagination v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

@yubisaki/vuepress-plugin-pagination

Install

npm i @yubisaki/vuepress-plugin-pagination

Usage

module.exports = {
  plugins: ['@yubisaki/vuepress-plugin-pagination']
}

Options

postsFilter

  • Type: function

  • default:

(pageContext) => pageContext.type === 'post'

This function is used to filter pages, the default value filter the pages which type is post

postsSorter

  • Type: function

  • default:

(prev, next) => {
  const prevTime = new Date(prev.frontmatter.date).getTime()
  const nextTime = new Date(next.frontmatter.date).getTime()
  return prevTime - nextTime > 0 ? -1 : 1
}

This function is used to sort pages, the default value is to sort pages by page.frontmatter.date

perPagePosts

  • Type: number

  • default: 5

This option is the count of posts which per page will show

paginationDir

  • Type: string

  • default: page

This option is the pagination path, such as xxx.blog/page/1, xxx.blog/page/2

firstPagePath

  • Type: string

  • default: /

This option is the first pagination path, equivalent to xxx.blog/page/1

layout

  • Type: string

  • default: Layout

This option is the layout wich pagination page will be used

example

module.exports = {
  plugins: ['@yubisaki/pagination', {
    postsFilter,
    postsSorter,
    perPagePosts,
    paginationDir,
    firstPagePath,
    layout
  }]
}

What can you get?

Vue.computed.$pagination: The property support pagination data

$pagination has the below property:

  • all: All pages

  • pages: The Array of pagination

  • length The length of the pages property

  • currentIndex: The current page index

  • posts: The posts of the current page

  • hasPrev: If the current post has previous post

  • hashNext: If the current post has next post

  • prevLink: The link of the previous page

  • nextLink: The link of the next page