Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
fix: $pagination.getSpecificPageLink doesn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
ulivz committed Jun 14, 2019
1 parent ef222b5 commit 98a5d69
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@
"typescript/explicit-function-return-type": "off",
"no-throw-literal": "off",
"typescript/no-var-requires": "off",
"no-implicit-globals": "off"
"no-implicit-globals": "off",
"import/no-unresolved": "off",
"import/no-extraneous-dependencies": "off"
}
},
"husky": {
Expand Down
46 changes: 24 additions & 22 deletions src/client/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,6 @@ import _debug from 'debug'

const debug = _debug('plugin-blog:pagination')

class PaginationGateway {
constructor(paginations) {
this.paginations = paginations
}

get pages() {
return Vue.$vuepress.$get('siteData').pages
}

getPagination(pid, id, route) {
debug('id', id)
debug('this.paginations', this.paginations)
const pagnination = this.paginations.filter(
p => p.id === id && p.pid === pid,
)[0]
return new Pagination(pagnination, this.pages, route)
}
}

const gateway = new PaginationGateway(paginations)

class Pagination {
constructor(pagination, pages, route) {
debug(pagination)
Expand Down Expand Up @@ -72,6 +51,7 @@ class Pagination {
}
return this._paginationPages[this.paginationIndex - 1].path
}
return null
}

get hasNext() {
Expand All @@ -82,13 +62,35 @@ class Pagination {
if (this.hasNext) {
return this._paginationPages[this.paginationIndex + 1].path
}
return null
}

getSpecificPageLink(index) {
return this._paginationPages[this.paginationIndex + 1].path
return this._paginationPages[index].path
}
}

class PaginationGateway {
constructor(paginations) {
this.paginations = paginations
}

get pages() {
return Vue.$vuepress.$get('siteData').pages
}

getPagination(pid, id, route) {
debug('id', id)
debug('this.paginations', this.paginations)
const pagnination = this.paginations.filter(
p => p.id === id && p.pid === pid,
)[0]
return new Pagination(pagnination, this.pages, route)
}
}

const gateway = new PaginationGateway(paginations)

export default ({ Vue }) => {
Vue.mixin({
methods: {
Expand Down

0 comments on commit 98a5d69

Please sign in to comment.