2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-24 13:12:19 +03:00

Allow titleTemplate to be a function

This commit is contained in:
Sean
2017-09-08 12:54:09 -07:00
parent 7484adc70d
commit c3cc4bdae4
+4
View File
@@ -84,8 +84,12 @@ export default function _getMetaInfo (options = {}) {
// replace title with populated template // replace title with populated template
if (info.titleTemplate) { if (info.titleTemplate) {
if (typeof info.titleTemplate === 'function') {
info.title = info.titleTemplate(info.titleChunk)
} else {
info.title = info.titleTemplate.replace(/%s/g, info.titleChunk) info.title = info.titleTemplate.replace(/%s/g, info.titleChunk)
} }
}
// convert base tag to an array so it can be handled the same way // convert base tag to an array so it can be handled the same way
// as the other tags // as the other tags