diff --git a/src/lib/components/ChatContent.svelte b/src/lib/components/ChatContent.svelte index 3e0098d..50c286b 100644 --- a/src/lib/components/ChatContent.svelte +++ b/src/lib/components/ChatContent.svelte @@ -1,6 +1,7 @@ + + + +{#snippet postList(items: UserPost[], empty: string)} + {#if items.length === 0} +

{empty}

+ {:else} + + {/if} +{/snippet} + +
+ {#if !pubkey} +

Profile

+

+ Profile not found. +

+ {:else} +

{name}

+ +
+
+ {#if entry?.nip05} +

+ {entry.nip05} +

+ {/if} + + {#if entry?.about} +

+ {entry.about} +

+ {/if} + +
+ {#if entry?.website} + + {websiteLabel(entry.website)} + + {/if} + {#if entry?.lud16} + + ⚡ {entry.lud16} + + {/if} + + View on njump ↗ + +
+
+ + {#if entry?.picture} + + {:else} + + {/if} +
+ +
+
+

+ Discussions +

+ {#if !posts} +

+ Loading… +

+ {:else} + {@render postList(posts.roots, "No discussions yet.")} + {/if} +
+ +
+

+ Replies +

+ {#if !posts} +

+ Loading… +

+ {:else} + {@render postList(posts.replies, "No replies yet.")} + {/if} +
+
+ {/if} +
diff --git a/src/routes/profile/[id]/+page.ts b/src/routes/profile/[id]/+page.ts new file mode 100644 index 0000000..d3de4d5 --- /dev/null +++ b/src/routes/profile/[id]/+page.ts @@ -0,0 +1,24 @@ +import { redirect } from "@sveltejs/kit"; +import * as nip19 from "@nostr/tools/nip19"; +import { decodeProfileId } from "$lib/forum/profiles"; +import { snapshot, type Profiles } from "$lib/forum/snapshot"; +import type { UserPosts } from "$lib/forum/userPosts"; + +// nprofile and hex forms redirect to the canonical npub URL. An invalid id +// is a server 404 (via the endpoint) and an in-page message on the client. +export async function load({ fetch, params }) { + const pubkey = decodeProfileId(params.id); + if (pubkey) { + const npub = nip19.npubEncode(pubkey); + if (params.id !== npub) redirect(301, `/profile/${npub}`); + } + const data = await snapshot<{ posts: UserPosts; profiles: Profiles }>( + fetch, + `/api/profile/${params.id}`, + ); + return { + pubkey, + posts: data?.posts ?? null, + profiles: data?.profiles ?? null, + }; +} diff --git a/src/routes/thread/[id]/+page.svelte b/src/routes/thread/[id]/+page.svelte index 8e36491..2903a22 100644 --- a/src/routes/thread/[id]/+page.svelte +++ b/src/routes/thread/[id]/+page.svelte @@ -26,6 +26,7 @@ import { setActiveGroup } from "$lib/active.svelte"; import { applyHighlights, clearHighlights } from "$lib/pageHighlight"; import { RELAY_URL, MODE } from "$lib/config"; + import { profilePath } from "$lib/forum/profiles"; import ThreadScrubber from "$lib/components/ThreadScrubber.svelte"; import MessageEditor from "$lib/components/MessageEditor.svelte"; import PostContent from "$lib/components/PostContent.svelte"; @@ -373,20 +374,31 @@ )} {@const author = resolveAuthor(p.pubkey, profiles)}
-