Skip to content

Commit

Permalink
fix: fix title inferrence regression (close #208)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 23, 2018
1 parent c37bfb9 commit 52c20cf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
12 changes: 11 additions & 1 deletion lib/app/dataMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,17 @@ export default {
return targetLang || defaultLang || {}
},
$title () {
return this.$page.frontmatter.title || this.$localeConfig.title || this.$site.title || ''
const page = this.$page
const siteTitle = this.$localeConfig.title || this.$site.title || ''
const selfTitle = page.frontmatter.home ? null : (
page.frontmatter.title || // explicit title
page.title // inferred title
)
return siteTitle
? selfTitle
? (siteTitle + ' | ' + selfTitle)
: siteTitle
: selfTitle || 'VuePress'
},
$description () {
return this.$page.frontmatter.description || this.$localeConfig.description || this.$site.description || ''
Expand Down
12 changes: 0 additions & 12 deletions lib/app/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,3 @@ export function findPageForPath (pages, path) {
}
}
}

export function getTitle (siteTitle, page) {
const selfTitle = page.frontmatter.home ? null : (
page.frontmatter.title || // explicit title
page.title // inferred title
)
return siteTitle
? selfTitle
? (siteTitle + ' | ' + selfTitle)
: siteTitle
: selfTitle || 'VuePress'
}
6 changes: 3 additions & 3 deletions lib/default-theme/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Home from './Home.vue'
import Navbar from './Navbar.vue'
import Page from './Page.vue'
import Sidebar from './Sidebar.vue'
import { pathToComponentName, getTitle, getLang } from '@app/util'
import { pathToComponentName } from '@app/util'
import { resolveSidebarItems } from './util'
export default {
Expand Down Expand Up @@ -76,7 +76,7 @@ export default {
created () {
if (this.$ssrContext) {
this.$ssrContext.title = getTitle(this.$title, this.$page)
this.$ssrContext.title = this.$title
this.$ssrContext.lang = this.$lang
this.$ssrContext.description = this.$page.description || this.$description
}
Expand All @@ -87,7 +87,7 @@ export default {
// update title / meta tags
this.currentMetaTags = []
const updateMeta = () => {
document.title = getTitle(this.$title, this.$page)
document.title = this.$title
document.documentElement.lang = this.$lang
const meta = [
{
Expand Down

0 comments on commit 52c20cf

Please sign in to comment.