I am using the net Nuxt boilterplate for NetlifyCMS and it all works good, but I have a hard time figuring out how to set meta description on a blog post.
My _blog.vue template has this
<template>
<article>
<h1>{{ blogPost.title }}</h1>
<div v-html="$md.render(blogPost.body)" />
</article>
</template>
<script>
export default {
async asyncData({ params, payload }) {
if (payload) {
this.blogPost = payload
return {
blogPost: payload
}
} else {
return {
blogPost: await require(`~/assets/content/blog/${params.blog}.json`)
}
}
}
}
</script>
I can't figure out how to set the
head () {
return {
title: blogPost.metatitle,
meta: [
// hid is used as unique identifier. Do not use `vmid` for it as it will not work
{ hid: 'description', name: 'description', content: blogPost.metadescription }
]
}
}
It obviously doesn't work as blogPost is undefined inside the head function. But I'm unsure where to place it, so it blogPost.metadescription has a value.