Fix tag issue

Signed-off-by: nurRiyad <asadnurriyad@gmail.com>
This commit is contained in:
nurRiyad
2023-11-18 15:54:17 +06:00
parent 475f563117
commit 214458e9cb
4 changed files with 25 additions and 28 deletions

View File

@@ -12,18 +12,18 @@ const category = computed(() => {
return strName
})
const { data } = await useAsyncData('home', () =>
const { data } = await useAsyncData(`category-data-${category.value}`, () =>
queryContent('/blogs')
.where({ tags: { $contains: category.value } })
.find(),
)
const formatedData = computed(() => {
const formattedData = computed(() => {
return data.value?.map((articles) => {
return {
path: articles._path,
title: articles.title || 'no-title available',
description: articles.description || 'no-descriptoin available',
description: articles.description || 'no-description 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',
@@ -52,22 +52,20 @@ defineOgImage()
<main class="container max-w-5xl mx-auto text-zinc-600">
<CategoryTopic />
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
<template v-for="post in formatedData" :key="post.title">
<BlogCard
:path="post.path"
:title="post.title"
:date="post.date"
:description="post.description"
:image="post.image"
:alt="post.alt"
:og-image="post.ogImage"
:tags="post.tags"
:published="post.published"
/>
</template>
<template v-if="data?.length === 0">
<BlogEmpty />
</template>
<BlogCard
v-for="post in formattedData"
:key="post.title"
:path="post.path"
:title="post.title"
:date="post.date"
:description="post.description"
:image="post.image"
:alt="post.alt"
:og-image="post.ogImage"
:tags="post.tags"
:published="post.published"
/>
<BlogEmpty v-if="data?.length === 0" />
</div>
</main>
</template>

View File

@@ -24,7 +24,7 @@ useHead({
{
name: 'description',
content:
'Blow All the topics are listed on which either I have written a blog or will write a blog in near future.',
'Below All the topics are listed on which either I have written a blog or will write a blog in near future.',
},
],
titleTemplate: 'Riyad\'s Blog - %s',
@@ -37,9 +37,7 @@ defineOgImage()
<main class="container max-w-5xl mx-auto text-zinc-600">
<CategoryHero />
<div class="flex flex-wrap px-6 mt-12 gap-3">
<template v-for="topic in topics" :key="topic">
<CategoryCard :title="makeFirstCharUpper(topic)" />
</template>
<CategoryCard v-for="topic in topics" :key="topic" :title="makeFirstCharUpper(topic)" />
</div>
</main>
</template>