refactor tag counting logic for clarity

This commit is contained in:
fiatcode 2026-01-22 15:20:41 +07:00
parent 8ba5ee800f
commit 80633f89aa

View file

@ -6,7 +6,8 @@ const posts = await getCollection("blog");
const tagsMap = new Map<string, number>();
posts.forEach((post) => {
post.data.tags?.forEach((tag) => {
tagsMap.set(tag, (tagsMap.get(tag) || 0) + 1);
const currentCount = tagsMap.get(tag) || 0;
tagsMap.set(tag, currentCount + 1);
});
});
const tags = Array.from(tagsMap.entries()).sort((a, b) =>