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:
Badri Sunderarajan 2020-03-15 15:05:22 +05:30
parent 309589bb63
commit abdaff4a7f
1 changed files with 8 additions and 0 deletions

View File

@ -89,6 +89,7 @@ export default {
},
methods: {
getPreviousNext() {
this.PreviousNexts = []
const allBlogs = this.$static.allGhostPost.edges;
for (let i = 0; i < allBlogs.length; i++) {
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>