We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1992259 commit 5689790Copy full SHA for 5689790
1 file changed
lib/posts/api.ts
@@ -73,7 +73,14 @@ export async function getPostSlugs() {
73
export async function getPostsCategories() {
74
const posts = await getPosts();
75
76
- return [...new Set(posts.flatMap((post) => post.data.categories))];
+ const uniqueCategories = posts.reduce((acc, post) => {
77
+ post.data.categories.forEach((category) => {
78
+ acc.add(category.trim().toLowerCase());
79
+ });
80
+ return acc;
81
+ }, new Set());
82
+
83
+ return [...uniqueCategories];
84
}
85
86
export function filterPostsByCategory(posts: Post[], category: string): Post[] {
0 commit comments