Fix blog post title

This commit is contained in:
2021-04-18 14:32:12 +02:00
parent 99c2727ae6
commit 6da0d9df02

View File

@@ -111,7 +111,7 @@ import {
useContext, useContext,
useFetch, useFetch,
useMeta, useMeta,
useRoute, useStatic useRoute, useStatic, watch
} from "@nuxtjs/composition-api"; } from "@nuxtjs/composition-api";
import {Post} from "../../../@types/types"; import {Post} from "../../../@types/types";
@@ -121,6 +121,7 @@ export default defineComponent({
setup() { setup() {
const {$content, i18n, $axios, app, $storage} = useContext() const {$content, i18n, $axios, app, $storage} = useContext()
const route = useRoute() const route = useRoute()
const { title } = useMeta()
const slug = computed(() => route.value.params.slug) const slug = computed(() => route.value.params.slug)
const post = useStatic((slug) => { const post = useStatic((slug) => {
@@ -131,8 +132,8 @@ export default defineComponent({
}) as Promise<Post> }) as Promise<Post>
}, slug, 'post') }, slug, 'post')
useMeta({ watch(post, () => {
title: `Blog - Arthur Danjou - ${post.value?.title}` title.value = `Blog - Arthur Danjou - ${post.value?.title || 'Loading title...'}`
}) })
const liked = ref($storage.getCookie(`${slug.value}`) !== undefined) const liked = ref($storage.getCookie(`${slug.value}`) !== undefined)