npm i @yubisaki/vuepress-plugin-paginationmodule.exports = {
plugins: ['@yubisaki/vuepress-plugin-pagination']
}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
module.exports = {
plugins: ['@yubisaki/pagination', {
postsFilter,
postsSorter,
perPagePosts,
paginationDir,
firstPagePath,
layout
}]
}Vue.computed.$pagination: The property support pagination data
$pagination has the below property:
-
all: All pages -
pages: The Array of pagination -
lengthThe length of thepagesproperty -
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