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,