From abdaff4a7fe18055139dcd3fb63b104fc336ef7a Mon Sep 17 00:00:00 2001 From: Badri Sunderarajan Date: Sun, 15 Mar 2020 15:05:22 +0530 Subject: [PATCH] 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. --- src/components/PreviousNext.vue | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/PreviousNext.vue b/src/components/PreviousNext.vue index 98d00ab..a7db399 100644 --- a/src/components/PreviousNext.vue +++ b/src/components/PreviousNext.vue @@ -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() + } } };