Fix 404 issue

Signed-off-by: nurRiyad <asadnurriyad@gmail.com>
This commit is contained in:
nurRiyad
2023-09-02 21:47:16 +06:00
parent a4f6c2a328
commit 959225092d
2 changed files with 14 additions and 47 deletions

View File

@@ -1,37 +0,0 @@
<script setup lang="ts">
defineProps({
code: {
type: String,
default: '',
},
language: {
type: String,
default: null,
},
filename: {
type: String,
default: null,
},
highlights: {
type: Array as () => number[],
default: () => [],
},
meta: {
type: String,
default: null,
},
})
</script>
<template>
<div>
<slot />
</div>
</template>
<style>
pre code .line {
display: block;
min-height: 1rem;
}
</style>

View File

@@ -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<BlogPost>(() => {
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({
<div
class="prose prose-pre:max-w-xs sm:prose-pre:max-w-full prose-sm sm:prose-base md:prose-lg prose-h1:no-underline max-w-5xl mx-auto prose-zinc prose-img:rounded-lg"
>
<ContentRenderer :value="articles">
<ContentRenderer v-if="articles" :value="articles">
<template #empty>
<p>No content found.</p>
</template>