From 959225092d18777065b83d2392959ad56190afaa Mon Sep 17 00:00:00 2001 From: nurRiyad Date: Sat, 2 Sep 2023 21:47:16 +0600 Subject: [PATCH] Fix 404 issue Signed-off-by: nurRiyad --- components/content/ProseCode.vue | 37 -------------------------------- pages/blogs/[blog].vue | 24 ++++++++++++--------- 2 files changed, 14 insertions(+), 47 deletions(-) delete mode 100644 components/content/ProseCode.vue diff --git a/components/content/ProseCode.vue b/components/content/ProseCode.vue deleted file mode 100644 index ba756b9..0000000 --- a/components/content/ProseCode.vue +++ /dev/null @@ -1,37 +0,0 @@ - - - - - diff --git a/pages/blogs/[blog].vue b/pages/blogs/[blog].vue index bcd0a8e..d2cf679 100644 --- a/pages/blogs/[blog].vue +++ b/pages/blogs/[blog].vue @@ -2,18 +2,22 @@ import type { BlogPost } from '@/types/blog' const { path } = useRoute() -const articles = await queryContent(path).findOne() + +const { data: articles, error } = await useAsyncData(`blog-post-${path}`, () => queryContent(path).findOne()) + +if (error.value) + navigateTo('/404') const data = computed(() => { return { - title: articles.title || 'no-title available', - description: articles.description || 'no-descriptoin available', - image: articles.image || '/nuxt-blog/no-image_cyyits.png', - alt: articles.alt || 'no alter data available', - ogImage: articles.ogImage || '/nuxt-blog/no-image_cyyits.png', - date: articles.date || 'not-date-available', - tags: articles.tags || [], - published: articles.published || false, + title: articles.value?.title || 'no-title available', + description: articles.value?.description || 'no-descriptoin available', + image: articles.value?.image || '/nuxt-blog/no-image_cyyits.png', + alt: articles.value?.alt || 'no alter data available', + ogImage: articles.value?.ogImage || '/nuxt-blog/no-image_cyyits.png', + date: articles.value?.date || 'not-date-available', + tags: articles.value?.tags || [], + published: articles.value?.published || false, } }) @@ -87,7 +91,7 @@ useHead({
- +