Skip to content

Commit

Permalink
fix: set variables on SSR from asyncData
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Jul 8, 2021
1 parent a6b2d6a commit fb9e062
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/app/pages/_.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ export default defineComponent({
templateOptions = { ...templateOptions, ...page.layout }
}
if (process.server) {
// Set template options
$docus.layout.value = templateOptions
// Set Docus runtime current page
$docus.currentPage.value = page
// Update navigation path to update currentNav
$docus.currentPath.value = `/${params.pathMatch}`
}
// Redirect to another page if `navigation.redirect` is declared
if (page.navigation && page.navigation.redirect) redirect(localePath(page.navigation.redirect))
Expand Down Expand Up @@ -111,13 +121,15 @@ export default defineComponent({
}
},
created() {
// Set template options
this.$docus.layout.value = this.templateOptions
// Set Docus runtime current page
this.$docus.currentPage.value = this.page
// Update navigation path to update currentNav
this.$docus.currentPath.value = `/${this.$route.params.pathMatch}`
if (process.client) {
// Set template options
this.$docus.layout.value = this.templateOptions
// Set Docus runtime current page
this.$docus.currentPage.value = this.page
// Update navigation path to update currentNav
this.$docus.currentPath.value = `/${this.$route.params.pathMatch}`
}
},
mounted() {
if (this.page?.version) localStorage.setItem(`page-${this.page.slug}-version`, this.page.version)
Expand Down

0 comments on commit fb9e062

Please sign in to comment.