diff --git a/src/lib/posts.ts b/src/lib/posts.ts index 0c31b6e..e5cbcf7 100644 --- a/src/lib/posts.ts +++ b/src/lib/posts.ts @@ -27,7 +27,7 @@ export async function getPosts(tag: string | null = null) { return posts; } -export async function getTags() { +export async function getTags() : Promise> { const allPostFiles = import.meta.glob('$content/post/*.md'); const iterablePostFiles = Object.entries(allPostFiles); @@ -37,5 +37,7 @@ export async function getTags() { 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}