From 7038e47c75d5f56ee60f5c8abfbea2f4c91a8c9c Mon Sep 17 00:00:00 2001 From: webfussel Date: Thu, 17 Jul 2025 13:48:11 +0200 Subject: [PATCH] fix: filter filter also reacting to external posts --- app/pages/blog/index.vue | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/pages/blog/index.vue b/app/pages/blog/index.vue index 5389ab0..2fa787f 100644 --- a/app/pages/blog/index.vue +++ b/app/pages/blog/index.vue @@ -48,17 +48,6 @@ const firstTen = computed(() => { return (articles.value?.slice(0, 10) ?? []).map(makeBlogCard) }) -const allCategoriesAndCount = computed>(() => { - const categories = {} as Record - articles.value?.forEach(article => { - const category = article.category as Category - if (category) { - categories[category] = (categories[category] ?? 0) + 1 - } - }) - return categories -}) - const { data: externalPostsRaw } = useFetch('/api/external-posts', { method: 'POST' }) const externalPosts = computed(() => externalPostsRaw.value?.flatMap(externalBlog => { @@ -75,6 +64,18 @@ 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 allCategoriesAndCount = computed>(() => { + const categories = {} as Record + articles.value?.forEach(article => { + const category = article.category as Category + if (category) { + categories[category] = (categories[category] ?? 0) + 1 + } + }) + categories['extern'] = externalPosts.value?.length ?? 0 + return categories +}) + const makeBlogCard = (article: BlogCollectionItem): BlogCard => ({ title: article.title, description: article.description,