diff --git a/src/lib/posts.ts b/src/lib/posts.ts index 93359ee..d0fe91f 100644 --- a/src/lib/posts.ts +++ b/src/lib/posts.ts @@ -38,7 +38,7 @@ export async function getPosts(tag: string | null = null) : Promise { return posts; } -export async function getTags() : Promise> { +export async function getTags() : Promise> { const allPostFiles = import.meta.glob('$content/post/*.md'); const iterablePostFiles = Object.entries(allPostFiles); @@ -48,5 +48,7 @@ export async function getTags() : Promise> { return metadata.tags; }) ); - return new Set(allPosts.flat()); + return allPosts.flat().reduce((acc: Map, curr: string) => { + return acc[curr] ? ++acc[curr] : acc[curr] = 1, acc + }, new Map()); } diff --git a/src/routes/tag/+page.svelte b/src/routes/tag/+page.svelte index b0b49de..7d60e17 100644 --- a/src/routes/tag/+page.svelte +++ b/src/routes/tag/+page.svelte @@ -12,15 +12,22 @@

Tags


-
- {#each allTags as tag} - {tag} +
+ {#each Object.entries(allTags) as [tag, occ]} +
+ {tag} + ({occ}) +
{/each}