Hi,
is it possible to use a template like titleTemplate for other properties?
Use case:
metaInfo () {
return {
title: 'My default title',
titleTemplate: '%s | My default title template',
meta: [
...
]
}
}
metaInfo () {
return {
title: 'I'm a vue component',
meta: [
{ property: 'og:title', content: 'My component title' }
]
}
}
I want to have og:title the same as title. Title gets parsed with the template set in app.vue.
In this case:
title = I'm a vue component | My default title template
og:title = My component title
How can I make them the same without removing the template?
Thank you in advance!
Hi @hurradieweltgehtunter
Saldy it's not possible right now, but I'm open to discuss about a possible solution, what do you have in mind to accomplish this?
Please mention me so I can keep track of this issue.
Thx @Atinux for answering.
It would be cool to have a template option like in title. So one could define a default property + template and reuses this in every component. If it isn't defined in a component, the default value is used.
Example:
metaInfo () {
return {
title: 'My default title',
titleTemplate: '%s | My default title template',
meta: [
{ property: 'og:title', content: 'My title', template: '% | My default template value' } // results in "My title | My default template value"
]
}
}
metaInfo () {
return {
title: 'My component title',
meta: [
{ property: 'og:title', content: 'My custom title' } // results in "My custom title | My default template value"
]
}
}
It's just analog to title and titleTemplate
the template option inside the meta-property could be set in every component and could be valid for all subordinate components (but, maybe this is V2 :) )
I see, it's a good idea indeed.
It's a template key for meta tags where %s is replaced by the content key.
Right know I have a lot of work with Nuxt.js, but if someone want to open a PR to add this feature, please do :)
@Atinux done :)
Most helpful comment
@Atinux done :)