fix: filtering works now

Fix wrong filtering
This commit is contained in:
webfussel 2025-08-18 14:52:30 +02:00
parent 2466e7dc89
commit 85d2ad60a2

View file

@ -62,7 +62,14 @@ const externalPosts = computed<BlogCard[]>(() => externalPostsRaw.value?.flatMap
}))
}) ?? [])
const allPosts = computed<BlogCard[]>(() => [...(firstTen.value ?? []), ...(externalPosts.value ?? [])].sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()))
const allPosts = computed<BlogCard[]>(() => {
const allPosts = [...firstTen.value, ...externalPosts.value]
allPosts.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())
if (route.query.category && Object.keys(allCategoriesAndCount.value).includes(route.query.category as Category)) {
return allPosts.filter(article => article.category === route.query.category)
}
return allPosts
})
const allCategoriesAndCount = computed<Record<Category, number>>(() => {
const categories = {} as Record<Category, number>