Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move ssrContext setting to core (#349, #370) #376

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/app/dataMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,12 @@ export default {
this.$route.path
)
}
},
created () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't be placed here, or it will be invoked for each component.

Copy link
Member Author

@meteorlxy meteorlxy May 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't put it here, we have some other choices:

  1. Ask users to put it mannually into the custom Layout.vue
  2. Wrap the themeLayout with another component, to which inject this snippets. fix: move ssrContext and updateMeta to core (#349, #370)  #389

if (this.$ssrContext) {
this.$ssrContext.title = this.$title
this.$ssrContext.lang = this.$lang
this.$ssrContext.description = this.$page.description || this.$description
}
}
}
4 changes: 4 additions & 0 deletions lib/app/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ export function findPageForPath (pages, path) {
return page
}
}
return {
path: '',
frontmatter: {}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it to fix some bugs, or?

Copy link
Member Author

@meteorlxy meteorlxy May 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this, there will be errors rendering NotFound.vue, as there is no $page match it. So we have to return an empty page data.

Copy link
Member Author

@meteorlxy meteorlxy May 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact it to fix a bug, and this bug has something to do with this PR.

I'll extract it to another PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
8 changes: 0 additions & 8 deletions lib/default-theme/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,6 @@ export default {
}
},

created () {
if (this.$ssrContext) {
this.$ssrContext.title = this.$title
this.$ssrContext.lang = this.$lang
this.$ssrContext.description = this.$page.description || this.$description
}
},

mounted () {
// update title / meta tags
this.currentMetaTags = []
Expand Down