From ce03876fed615c5c6f8ae36c68f9775faa33bc9b Mon Sep 17 00:00:00 2001 From: dtonon Date: Thu, 9 Apr 2026 17:13:20 +0100 Subject: [PATCH] Add labels to the listing --- src/lib/components/ThreadItem.svelte | 8 ++++++++ src/lib/threads.svelte.ts | 2 ++ src/routes/+page.svelte | 1 + 3 files changed, 11 insertions(+) diff --git a/src/lib/components/ThreadItem.svelte b/src/lib/components/ThreadItem.svelte index 6ed9f91..77d8aaa 100644 --- a/src/lib/components/ThreadItem.svelte +++ b/src/lib/components/ThreadItem.svelte @@ -10,6 +10,7 @@ export type ThreadRow = { id: string; title: string; + labels: string[]; author: Author; replyCount: number; repliers: Author[]; @@ -54,6 +55,13 @@ {/each} {/if} + {#if thread.labels.length > 0} +
+ {#each thread.labels as l} + + {/each} +
+ {/if} diff --git a/src/lib/threads.svelte.ts b/src/lib/threads.svelte.ts index 9a81331..2e2db38 100644 --- a/src/lib/threads.svelte.ts +++ b/src/lib/threads.svelte.ts @@ -5,6 +5,7 @@ import { RELAY_URL, GROUP_ID } from "$lib/config"; export type ThreadData = { id: string; title: string; + labels: string[]; authorPubkey: string; createdAt: number; replyCount: number; @@ -42,6 +43,7 @@ export async function loadThreads() { threads = events.map((e) => ({ id: e.id, title: e.tags.find((t) => t[0] === "title")?.[1] ?? "(untitled)", + labels: e.tags.filter((t) => t[0] === "t" && t[1]).map((t) => t[1]), authorPubkey: e.pubkey, createdAt: e.created_at, replyCount: 0, diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 67c4c4f..87f2501 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -49,6 +49,7 @@ return { id: t.id, title: t.title, + labels: t.labels, author: resolveAuthor(t.authorPubkey, profiles), replyCount: t.replyCount, repliers: t.replierPubkeys.map((pk) => resolveAuthor(pk, profiles)),