Updated SEO.

Signed-off-by: Pavel Kirilin <win10@list.ru>
This commit is contained in:
2021-12-08 03:00:46 +04:00
parent d9e945ee92
commit 347edeea90
5 changed files with 43 additions and 6 deletions

View File

@ -6,17 +6,20 @@
<script>
import {
defineComponent,
useContext,
ref,
onMounted,
useMeta,
useStore,
onMounted,
useContext,
defineComponent,
} from '@nuxtjs/composition-api'
import Prism from '~/plugins/prism'
export default defineComponent({
head() {},
setup() {
const page = ref({})
const { title, meta } = useMeta()
const { $content, params, error } = useContext()
const store = useStore()
// Finding current path's slug.
@ -26,6 +29,27 @@ export default defineComponent({
.fetch()
.then((doc) => {
page.value = doc
title.value = `${doc.title} - Dev blog`
const meta_data = [
{
hid: 'og:title',
name: 'og:title',
content: doc.title,
},
{
hid: 'og:description',
name: 'og:description',
content: doc.description,
},
]
if (doc.image) {
meta_data.push({
hid: 'og:description',
name: 'og:description',
content: doc.image,
})
}
meta.value = meta_data
})
.catch((_) => {
error({ statusCode: 404, message: 'Page not found' })
@ -47,7 +71,6 @@ export default defineComponent({
@import '@/static/css/global-styles.scss';
.nuxt-content {
padding-left: 15px;
padding-right: 15px;