2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-25 08:30:33 +03:00

Fixed SSR regression causing incorrect titles + chunked old title in case titleTemplate is present

This commit is contained in:
Declan de Wet
2016-10-30 17:53:57 +02:00
parent 8c43f47d64
commit b7a9817abf
+5 -12
View File
@@ -23,27 +23,19 @@
// update the meta info & the DOM // update the meta info & the DOM
Vue.mixin({ Vue.mixin({
mounted: function mounted () { mounted: function mounted () {
this.$root.$vueMeta.updateMetaInfo() this.$root.$vueMeta().updateMetaInfo()
} }
}) })
// guard against `$vueMeta` being redefined on new server requests
if (!Vue.prototype.hasOwnProperty('$vueMeta')) {
// define API methods on the `$vueMeta` instance property
Object.defineProperty(Vue.prototype, '$vueMeta', {
enumerable: true,
/** /**
* Meta info manager API factory * returns a cached manager API for use on the server
* @return {Object} - the API for this plugin * @return {Object} - manager (The programmatic API for this module)
*/ */
get: function get () { Vue.prototype.$vueMeta = function $vueMeta () {
_manager.getMetaInfo = _manager.getMetaInfo || Vue.util.bind(getMetaInfo, this) _manager.getMetaInfo = _manager.getMetaInfo || Vue.util.bind(getMetaInfo, this)
_manager.updateMetaInfo = _manager.updateMetaInfo || updateMetaInfo _manager.updateMetaInfo = _manager.updateMetaInfo || updateMetaInfo
return _manager return _manager
} }
})
}
/** /**
* Updates meta info and renders it to the DOM * Updates meta info and renders it to the DOM
@@ -62,6 +54,7 @@
function getMetaInfo () { function getMetaInfo () {
var info = getMetaInfoDefinition(Vue, this) var info = getMetaInfoDefinition(Vue, this)
if (info.titleTemplate) { if (info.titleTemplate) {
info.titleChunk = info.title
info.title = info.titleTemplate.replace('%s', info.title) info.title = info.titleTemplate.replace('%s', info.title)
} }
return info return info