Vue-meta: Template for other properties than title

Created on 26 Jul 2017  路  4Comments  路  Source: nuxt/vue-meta

Hi,
is it possible to use a template like titleTemplate for other properties?
Use case:

app.vue

metaInfo () {
  return  {
    title: 'My default title',
    titleTemplate: '%s | My default title template',
    meta: [
      ...
    ]
  }
}

component.vue

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!

enhancement

Most helpful comment

@Atinux done :)

All 4 comments

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:

app.vue

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"
    ]
  }
}

component.vue

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 :)

Was this page helpful?
0 / 5 - 0 ratings