refactor: change getMeta to async

This commit is contained in:
Clark Du 2017-11-24 12:11:52 +08:00 committed by Pooya Parsa
parent 30714c989a
commit 4cc4eefcf8

View File

@ -22,17 +22,13 @@ export default class MetaRenderer {
}) })
} }
getMeta(url) { async getMeta(url) {
return new Promise((resolve, reject) => {
const vm = new Vue({ const vm = new Vue({
render: (h) => h(), // Render empty html tag render: h => h(), // Render empty html tag
head: this.options.head || {} head: this.options.head || {}
}) })
this.vueRenderer.renderToString(vm, (err) => { await this.vueRenderer.renderToString(vm)
if (err) return reject(err) return vm.$meta().inject()
resolve(vm.$meta().inject())
})
})
} }
async render({ url = '/' }) { async render({ url = '/' }) {