2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-25 06:40: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
+10 -17
View File
@@ -23,26 +23,18 @@
// 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')) { * returns a cached manager API for use on the server
// define API methods on the `$vueMeta` instance property * @return {Object} - manager (The programmatic API for this module)
Object.defineProperty(Vue.prototype, '$vueMeta', { */
enumerable: true, Vue.prototype.$vueMeta = function $vueMeta () {
_manager.getMetaInfo = _manager.getMetaInfo || Vue.util.bind(getMetaInfo, this)
/** _manager.updateMetaInfo = _manager.updateMetaInfo || updateMetaInfo
* Meta info manager API factory return _manager
* @return {Object} - the API for this plugin
*/
get: function get () {
_manager.getMetaInfo = _manager.getMetaInfo || Vue.util.bind(getMetaInfo, this)
_manager.updateMetaInfo = _manager.updateMetaInfo || updateMetaInfo
return _manager
}
})
} }
/** /**
@@ -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