Skip to content

Commit 217abd3

Browse files
author
reco_luan
committed
fix(vuepress-plugin-pagation): fix invalid bug with perPage
ISSUES CLOSED: #265
1 parent ddf1484 commit 217abd3

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

packages/@vuepress-reco/vuepress-plugin-bulletin-popover/bin/Bulletin.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export default {
3737
return this.handleNode(this.body).join('')
3838
},
3939
footerNodes () {
40-
console.log(this.handleNode(this.footer))
4140
return this.handleNode(this.footer).join('')
4241
},
4342
bulletinLocales () {
@@ -54,7 +53,6 @@ export default {
5453
sessionStorage.setItem('closeNote', 'true')
5554
},
5655
handleNode (nodes) {
57-
console.log(nodes)
5856
if (!Array.isArray(nodes)) {
5957
let type = nodes.type
6058
type = type.slice(0, 1).toUpperCase() + type.slice(1)
Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
const { path } = require('@vuepress/shared-utils')
22

3-
module.exports = (options, context) => ({
4-
define () {
5-
const { perPage } = options || {}
6-
return {
7-
PERPAGE: perPage
8-
}
9-
},
10-
name: '@vuepress-reco/vuepress-plugin-pagation',
11-
enhanceAppFiles: [
12-
path.resolve(__dirname, './bin/enhanceAppFile.js')
13-
]
14-
})
3+
module.exports = (options, context) => {
4+
const { perPage = 10 } = options || {}
5+
return {
6+
define () {
7+
return {
8+
PERPAGE: perPage
9+
}
10+
},
11+
name: '@vuepress-reco/vuepress-plugin-pagation',
12+
enhanceAppFiles: [
13+
path.resolve(__dirname, './bin/enhanceAppFile.js'),
14+
() => ({
15+
name: 'dynamic-pagation',
16+
content: `export default ({ Vue }) => {
17+
Vue.mixin({
18+
computed: {
19+
$perPage () { return ${perPage} }
20+
}
21+
})
22+
}`
23+
})
24+
]
25+
}
26+
}

packages/vuepress-theme-reco/components/NoteAbstract.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export default {
1717
props: ['data', 'currentPage', 'currentTag'],
1818
computed: {
1919
currentPageData () {
20-
const start = this.currentPage * 10 - 10
21-
const end = this.currentPage * 10
20+
const start = (this.currentPage - 1) * this.$perPage
21+
const end = this.currentPage * this.$perPage
2222
return this.data.slice(start, end)
2323
}
2424
}

0 commit comments

Comments
 (0)