I'm trying to use Gridsome metaInfo
to create a Twitter Card with the Cover Image of the current post, but the image is not showing in the card.
<template>
<Layout>
...
<g-image ref="coverImage" alt="Cover image" v-if="$page.post.cover_image" :src="$page.post.cover_image" />
...
</Layout>
</template>
<script>
export default {
metaInfo () {
return {
title: this.$page.post.title,
meta: [{
property: 'og:image',
content: this.$refs.coverImage? this.$refs.coverImage.src : (this.$page.meta.siteUrl + '/logo/LOGO.png')
}]
}
}
}
</script>
<page-query>
query Post ($id: ID!) {
post: post (id: $id) {
title
path
cover_image (width: 860, blur: 10)
},
meta: metadata {
siteUrl
},
}
</page-query>
Since the g-image
know how to resolve the image path I have to use it in order to put the image path in the meta
tags.
Editors- this question is for documenting my knowledge, I know the answer and I hope the question will be good by itself