Bugfix: build fails if post doesn't have tags

Because how can you iterate over something that doesn't exist?
This commit is contained in:
Hippo 2020-04-26 22:31:45 +05:30
parent 4c42364083
commit 15905289e1

View file

@ -99,8 +99,10 @@ export default {
{ property: 'article:published_time', content: this.thisPost.date },
]
for (var i=0; i<this.thisPost.tags.length; i++) {
meta.push({ property: 'article:tag', content: this.thisPost.tags[i].title })
if (this.thisPost.tags) {
for (var i=0; i<this.thisPost.tags.length; i++) {
meta.push({ property: 'article:tag', content: this.thisPost.tags[i].title })
}
}
if (Admin.social_media && Admin.social_media.facebook) {
@ -116,7 +118,7 @@ export default {
{ property: 'twitter:label1', content: 'Written by' },
{ property: 'twitter:data1', content: this.thisPost.authors[0].name },
{ property: 'twitter:label2', content: 'Filed under' },
{ property: 'twitter:data2', content: this.thisPost.tags.map((t)=>{return t.title}).join(',') },
{ property: 'twitter:data2', content: this.thisPost.tags ? this.thisPost.tags.map((t)=>{return t.title}).join(',') : '' },
])
if (Admin.social_media && Admin.social_media.twitter) {