@@ -4,27 +4,6 @@ import _debug from 'debug'
4
4
5
5
const debug = _debug ( 'plugin-blog:pagination' )
6
6
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
-
28
7
class Pagination {
29
8
constructor ( pagination , pages , route ) {
30
9
debug ( pagination )
@@ -72,6 +51,7 @@ class Pagination {
72
51
}
73
52
return this . _paginationPages [ this . paginationIndex - 1 ] . path
74
53
}
54
+ return null
75
55
}
76
56
77
57
get hasNext ( ) {
@@ -82,13 +62,35 @@ class Pagination {
82
62
if ( this . hasNext ) {
83
63
return this . _paginationPages [ this . paginationIndex + 1 ] . path
84
64
}
65
+ return null
85
66
}
86
67
87
68
getSpecificPageLink ( index ) {
88
- return this . _paginationPages [ this . paginationIndex + 1 ] . path
69
+ return this . _paginationPages [ index ] . path
89
70
}
90
71
}
91
72
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
+
92
94
export default ( { Vue } ) => {
93
95
Vue . mixin ( {
94
96
methods : {
0 commit comments