@chavesweb/vuepress-plugin-pagination v1.0.1
@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 pagespages
: The Array of paginationlength
The length of thepages
propertycurrentIndex
: The current page indexposts
: The posts of the current pagehasPrev
: If the current post has previous posthashNext
: If the current post has next postprevLink
: The link of the previous pagenextLink
: The link of the next page
5 years ago