Seeking advice on a more efficient way to improve the code below and make it DRY:
<h2>{{ title }}</h2>
<p>{{ subtitle }}</p>
I am currently checking this.name for both the title and subtitle, wondering if there is a better implementation than what I have. Any suggestions?
computed: {
title() {
switch (this.name) {
case 'discounts_offers':
return this.$t('discounts.title');
case 'newsletter':
return this.$t('newsletters.title');
case 'product_upgrade':
return this.$t('upgrade.title');
default:
return this.name;
}
},
subtitle() {
switch (this.name) {
case 'discounts_offers':
return this.$t('discounts.subtitle');
case 'newsletter':
return this.$t('newsletters.subtitle');
case 'product_upgrade':
return this.$t('upgrade.subtitle');
default:
return this.name;
}
},
}