From 774e2da4639ad54fa7347f9d76a4c40a116f855e Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Mon, 6 Jul 2026 11:53:12 -0700 Subject: [PATCH] Add description to pins --- src/app/components/Pin.svelte | 3 ++ src/app/components/PinAdd.svelte | 4 +- src/app/components/PinEdit.svelte | 10 +++- src/app/components/PinForm.svelte | 48 ++++++++++++++++++- src/app/pinboards.ts | 8 ++-- .../[relay]/library/[address]/+page.svelte | 2 +- 6 files changed, 64 insertions(+), 11 deletions(-) diff --git a/src/app/components/Pin.svelte b/src/app/components/Pin.svelte index d7cccd2a..4b74aa2c 100644 --- a/src/app/components/Pin.svelte +++ b/src/app/components/Pin.svelte @@ -49,6 +49,9 @@ {pin.title} {/if} {/if} + {#if pin.description} + + {/if} {#if pin.value[0] === "i"} {:else} diff --git a/src/app/components/PinAdd.svelte b/src/app/components/PinAdd.svelte index 0e274722..d89c0903 100644 --- a/src/app/components/PinAdd.svelte +++ b/src/app/components/PinAdd.svelte @@ -10,12 +10,12 @@ const {url, address, reference}: Props = $props() - const submit = async ({title, topics, value}: PinFormValues) => { + const submit = async ({title, topics, value, content}: PinFormValues) => { const params = referenceToPin(value) if (!params) return "Please enter a valid URL or nostr link." - return createPin(url, {...params, boards: [address], title, topics}) + return createPin(url, {...params, boards: [address], title, topics, description: content}) } diff --git a/src/app/components/PinEdit.svelte b/src/app/components/PinEdit.svelte index 80caae8b..d823bf27 100644 --- a/src/app/components/PinEdit.svelte +++ b/src/app/components/PinEdit.svelte @@ -9,7 +9,7 @@ const {url, pin}: Props = $props() - const submit = async ({title, topics, value}: PinFormValues) => { + const submit = async ({title, topics, value, content}: PinFormValues) => { const params = referenceToPin(value) if (!params) return "Please enter a valid URL or nostr link." @@ -21,6 +21,7 @@ boards: pin.boards, title, topics, + description: content, }) } @@ -30,5 +31,10 @@ heading="Edit Link" action="Save changes" successMessage="Link updated!" - values={{title: pin.title, topics: pin.topics, value: pinToReference(pin)}} + values={{ + title: pin.title, + topics: pin.topics, + value: pinToReference(pin), + content: pin.description, + }} {submit} /> diff --git a/src/app/components/PinForm.svelte b/src/app/components/PinForm.svelte index e169ac7d..4a70ebea 100644 --- a/src/app/components/PinForm.svelte +++ b/src/app/components/PinForm.svelte @@ -3,11 +3,14 @@ title: string topics: string[] value: string + content: string } @@ -76,6 +94,29 @@ placeholder="Optional title" /> {/snippet} + + {#snippet label()} + Description + {/snippet} + {#snippet input()} +
+
+ +
+ +
+ {/snippet} +
{#snippet label()} Topics @@ -101,7 +142,10 @@ Go back - diff --git a/src/app/pinboards.ts b/src/app/pinboards.ts index 2c13dd79..3ac671bc 100644 --- a/src/app/pinboards.ts +++ b/src/app/pinboards.ts @@ -36,7 +36,7 @@ export type Pin = { pubkey: string identifier: string boards: string[] - comment: string + description: string title: string topics: string[] // The pin's content reference: the first e/a/i tag found, e.g. ["e", ], @@ -63,7 +63,7 @@ export const readPin = (event: TrustedEvent): Pin => ({ pubkey: event.pubkey, identifier: getTagValue("d", event.tags) ?? "", boards: getTagValues("A", event.tags), - comment: event.content, + description: event.content, title: getTagValue("title", event.tags) ?? "", topics: getTagValues("t", event.tags), value: event.tags.find(tag => ["e", "a", "i"].includes(tag[0])) ?? [], @@ -118,14 +118,14 @@ const makeBoardTemplate = ({ const makePinTemplate = ({ identifier = "", boards = [], - comment = "", + description = "", title = "", topics = [], value = [], }: Partial) => ({ kind: PIN, created_at: now(), - content: comment, + content: description, tags: [ // Reuse the identifier when editing so the addressable event is replaced; // fall back to a random one for new pins. diff --git a/src/routes/spaces/[relay]/library/[address]/+page.svelte b/src/routes/spaces/[relay]/library/[address]/+page.svelte index 6b9a6113..ea38068e 100644 --- a/src/routes/spaces/[relay]/library/[address]/+page.svelte +++ b/src/routes/spaces/[relay]/library/[address]/+page.svelte @@ -44,7 +44,7 @@ if (!value) return $pins return $pins.filter(pin => - [pin.title, pin.comment, pin.value[0] === "i" ? pin.value[1] : "", ...pin.topics].some( + [pin.title, pin.description, pin.value[0] === "i" ? pin.value[1] : "", ...pin.topics].some( field => field?.toLowerCase().includes(value), ), )