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

Commit 98a5d69

Browse files
committed
fix: $pagination.getSpecificPageLink doesn't work
1 parent ef222b5 commit 98a5d69

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@
6161
"typescript/explicit-function-return-type": "off",
6262
"no-throw-literal": "off",
6363
"typescript/no-var-requires": "off",
64-
"no-implicit-globals": "off"
64+
"no-implicit-globals": "off",
65+
"import/no-unresolved": "off",
66+
"import/no-extraneous-dependencies": "off"
6567
}
6668
},
6769
"husky": {

src/client/pagination.js

+24-22
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,6 @@ import _debug from 'debug'
44

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

7-
class PaginationGateway {
8-
constructor(paginations) {
9-
this.paginations = paginations
10-
}
11-
12-
get pages() {
13-
return Vue.$vuepress.$get('siteData').pages
14-
}
15-
16-
getPagination(pid, id, route) {
17-
debug('id', id)
18-
debug('this.paginations', this.paginations)
19-
const pagnination = this.paginations.filter(
20-
p => p.id === id && p.pid === pid,
21-
)[0]
22-
return new Pagination(pagnination, this.pages, route)
23-
}
24-
}
25-
26-
const gateway = new PaginationGateway(paginations)
27-
287
class Pagination {
298
constructor(pagination, pages, route) {
309
debug(pagination)
@@ -72,6 +51,7 @@ class Pagination {
7251
}
7352
return this._paginationPages[this.paginationIndex - 1].path
7453
}
54+
return null
7555
}
7656

7757
get hasNext() {
@@ -82,13 +62,35 @@ class Pagination {
8262
if (this.hasNext) {
8363
return this._paginationPages[this.paginationIndex + 1].path
8464
}
65+
return null
8566
}
8667

8768
getSpecificPageLink(index) {
88-
return this._paginationPages[this.paginationIndex + 1].path
69+
return this._paginationPages[index].path
8970
}
9071
}
9172

73+
class PaginationGateway {
74+
constructor(paginations) {
75+
this.paginations = paginations
76+
}
77+
78+
get pages() {
79+
return Vue.$vuepress.$get('siteData').pages
80+
}
81+
82+
getPagination(pid, id, route) {
83+
debug('id', id)
84+
debug('this.paginations', this.paginations)
85+
const pagnination = this.paginations.filter(
86+
p => p.id === id && p.pid === pid,
87+
)[0]
88+
return new Pagination(pagnination, this.pages, route)
89+
}
90+
}
91+
92+
const gateway = new PaginationGateway(paginations)
93+
9294
export default ({ Vue }) => {
9395
Vue.mixin({
9496
methods: {

0 commit comments

Comments
 (0)