diff --git a/app/pages/blog/index.vue b/app/pages/blog/index.vue index 2fa787f..c86a3dd 100644 --- a/app/pages/blog/index.vue +++ b/app/pages/blog/index.vue @@ -62,7 +62,14 @@ const externalPosts = computed(() => externalPostsRaw.value?.flatMap })) }) ?? []) -const allPosts = computed(() => [...(firstTen.value ?? []), ...(externalPosts.value ?? [])].sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())) +const allPosts = computed(() => { + 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>(() => { const categories = {} as Record