@@ -4,27 +4,6 @@ import _debug from 'debug'
44
55const 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-
287class 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+
9294export default ( { Vue } ) => {
9395 Vue . mixin ( {
9496 methods : {
0 commit comments