Merge pull request #31 from nurRiyad/fix-category

Fix tag issue
This commit is contained in:
Al Asad Nur Riyad
2023-11-18 15:56:26 +06:00
committed by GitHub
4 changed files with 25 additions and 28 deletions

View File

@@ -33,16 +33,17 @@ const picAColor = ref(`${color.at(getRandomInt(0, 8))}`)
<template> <template>
<div <div
class="text-[#F1F2F4] px-5 py-3 rounded hover:underline randbgcolor hover:scale-[1.05] transition-all duration-500" class="text-[#F1F2F4] px-5 py-3 rounded hover:underline
rand-bg-color hover:scale-[1.05] transition-all duration-500"
> >
<NuxtLink :to="`/categories/${title.toLocaleLowerCase()}`" class="text-xl font-extrabold"> <NuxtLink :to="`/categories/${title.toLocaleLowerCase()}`" class="text-lg font-extrabold">
<h1>#{{ title }}</h1> <h1>#{{ title }}</h1>
</NuxtLink> </NuxtLink>
</div> </div>
</template> </template>
<style scoped> <style scoped>
.randbgcolor { .rand-bg-color {
background-color: v-bind(picAColor); background-color: v-bind(picAColor);
} }
</style> </style>

View File

@@ -17,8 +17,8 @@ const category = computed(() => {
<template> <template>
<div class="container mx-auto"> <div class="container mx-auto">
<div class="p-6 my-4 mx-3 rounded-md bg-gray-200"> <div class="p-6 my-4 mx-3 rounded-md bg-gray-200 dark:bg-gray-800">
<h1 class="text-black font-semibold leading-tight text-4xl md:text-5xl my-5"> <h1 class="text-black dark:text-white font-semibold leading-tight text-xl md:text-2xl">
#{{ category }} #{{ category }}
</h1> </h1>
</div> </div>

View File

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

View File

@@ -24,7 +24,7 @@ useHead({
{ {
name: 'description', name: 'description',
content: 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', titleTemplate: 'Riyad\'s Blog - %s',
@@ -37,9 +37,7 @@ defineOgImage()
<main class="container max-w-5xl mx-auto text-zinc-600"> <main class="container max-w-5xl mx-auto text-zinc-600">
<CategoryHero /> <CategoryHero />
<div class="flex flex-wrap px-6 mt-12 gap-3"> <div class="flex flex-wrap px-6 mt-12 gap-3">
<template v-for="topic in topics" :key="topic"> <CategoryCard v-for="topic in topics" :key="topic" :title="makeFirstCharUpper(topic)" />
<CategoryCard :title="makeFirstCharUpper(topic)" />
</template>
</div> </div>
</main> </main>
</template> </template>