Update PreviousNext when navigating to a new page
Earlier, it was just computing it once and then leaving it there permanently. So you'd get "recommends" for the first post you opened rather than the current one, unless you went to a non-post page in the middle or reloaded the page.
This commit is contained in:
parent
309589bb63
commit
abdaff4a7f
1 changed files with 8 additions and 0 deletions
|
@ -89,6 +89,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getPreviousNext() {
|
getPreviousNext() {
|
||||||
|
this.PreviousNexts = []
|
||||||
const allBlogs = this.$static.allGhostPost.edges;
|
const allBlogs = this.$static.allGhostPost.edges;
|
||||||
for (let i = 0; i < allBlogs.length; i++) {
|
for (let i = 0; i < allBlogs.length; i++) {
|
||||||
if (allBlogs[i].node.id === this.currentPostId) {
|
if (allBlogs[i].node.id === this.currentPostId) {
|
||||||
|
@ -101,6 +102,13 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
id: function(val) {
|
||||||
|
console.log('Updating PreviousNext')
|
||||||
|
this.currentPostId = val
|
||||||
|
this.getPreviousNext()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue