diff --git a/src/lib/components/util/Details.svelte b/src/lib/components/util/Details.svelte
index e776e9d..f2fe837 100644
--- a/src/lib/components/util/Details.svelte
+++ b/src/lib/components/util/Details.svelte
@@ -11,10 +11,8 @@
let { event, isModal = false } = $props();
let title: string = $derived(getMatchingTags(event, 'title')[0]?.[1]);
- let author: string = $derived(getMatchingTags(event, 'author')[0]?.[1] ?? 'unknown');
let version: string = $derived(getMatchingTags(event, 'version')[0]?.[1] ?? '1');
let image: string = $derived(getMatchingTags(event, 'image')[0]?.[1] ?? null);
- let originalAuthor: string = $derived(getMatchingTags(event, 'p')[0]?.[1] ?? null);
let summary: string = $derived(getMatchingTags(event, 'summary')[0]?.[1] ?? null);
let type: string = $derived(getMatchingTags(event, 'type')[0]?.[1] ?? null);
let language: string = $derived(getMatchingTags(event, 'l')[0]?.[1] ?? null);
@@ -25,6 +23,12 @@
let rootId: string = $derived(getMatchingTags(event, 'd')[0]?.[1] ?? null);
let kind = $derived(event.kind);
+ let authorTag: string = $derived(getMatchingTags(event, 'author')[0]?.[1] ?? '');
+ let pTag: string = $derived(getMatchingTags(event, 'p')[0]?.[1] ?? '');
+
+ function isValidNostrPubkey(str: string): boolean {
+ return /^[a-f0-9]{64}$/i.test(str) || (str.startsWith('npub1') && str.length >= 59 && str.length <= 63);
+ }
@@ -32,7 +36,8 @@
{#if !isModal}
-
{@render userBadge(event.pubkey, author)}
+
+
{@render userBadge(event.pubkey, '')}
{/if}
@@ -46,10 +51,16 @@
{title}
by
- {#if originalAuthor !== null}
- {@render userBadge(originalAuthor, author)}
+ {#if authorTag && pTag && isValidNostrPubkey(pTag)}
+ {authorTag} {@render userBadge(pTag, '')}
+ {:else if authorTag}
+ {authorTag}
+ {:else if pTag && isValidNostrPubkey(pTag)}
+ {@render userBadge(pTag, '')}
+ {:else if authorTag}
+ {authorTag}
{:else}
- {author}
+ unknown
{/if}
{#if version !== '1' }
@@ -81,7 +92,7 @@
{:else}
Author:
{/if}
- {@render userBadge(event.pubkey, author)}
+ {@render userBadge(event.pubkey, '')}
diff --git a/src/lib/snippets/UserSnippets.svelte b/src/lib/snippets/UserSnippets.svelte
index d8c960e..7fc5632 100644
--- a/src/lib/snippets/UserSnippets.svelte
+++ b/src/lib/snippets/UserSnippets.svelte
@@ -1,18 +1,58 @@
{#snippet userBadge(identifier: string, displayText: string | undefined)}
- {#if toNpub(identifier)}
- {#await createProfileLinkWithVerification(toNpub(identifier) as string, displayText)}
- {@html createProfileLink(toNpub(identifier) as string, displayText)}
- {:then html}
- {@html html}
- {:catch}
- {@html createProfileLink(toNpub(identifier) as string, displayText)}
- {/await}
+ {@const npub = toNpub(identifier)}
+ {#if npub}
+ {#if !displayText || displayText.trim().toLowerCase() === 'unknown'}
+ {#await getUserMetadata(npub) then profile}
+ {@const p = profile as NostrProfileWithLegacy}
+
+
+
+ {:catch}
+
+
+
+ {/await}
+ {:else}
+ {#await createProfileLinkWithVerification(npub as string, displayText)}
+
+
+
+ {:then html}
+
+
+ {@html html.replace(/([\s\S]*<\/a>)/, '').trim()}
+
+ {:catch}
+
+
+
+ {/await}
+ {/if}
{:else}
{displayText ?? ''}
{/if}
diff --git a/src/lib/stores/userStore.ts b/src/lib/stores/userStore.ts
index 5c95ff8..3e3d77f 100644
--- a/src/lib/stores/userStore.ts
+++ b/src/lib/stores/userStore.ts
@@ -168,7 +168,7 @@ export async function loginWithAmber(amberSigner: NDKSigner, user: NDKUser) {
if (!ndk) throw new Error('NDK not initialized');
// Only clear previous login state after successful login
const npub = user.npub;
- const profile = await getUserMetadata(npub);
+ const profile = await getUserMetadata(npub, true); // Force fresh fetch
const [persistedInboxes, persistedOutboxes] = getPersistedRelays(user);
for (const relay of persistedInboxes) {
ndk.addExplicitRelay(relay);
diff --git a/src/lib/utils/nostrUtils.ts b/src/lib/utils/nostrUtils.ts
index b85dbb9..faa001b 100644
--- a/src/lib/utils/nostrUtils.ts
+++ b/src/lib/utils/nostrUtils.ts
@@ -46,11 +46,11 @@ function escapeHtml(text: string): string {
/**
* Get user metadata for a nostr identifier (npub or nprofile)
*/
-export async function getUserMetadata(identifier: string): Promise
{
+export async function getUserMetadata(identifier: string, force = false): Promise {
// Remove nostr: prefix if present
const cleanId = identifier.replace(/^nostr:/, '');
- if (npubCache.has(cleanId)) {
+ if (!force && npubCache.has(cleanId)) {
return npubCache.get(cleanId)!;
}
@@ -111,7 +111,8 @@ export function createProfileLink(identifier: string, displayText: string | unde
const defaultText = `${cleanId.slice(0, 8)}...${cleanId.slice(-4)}`;
const escapedText = escapeHtml(displayText || defaultText);
- return `@${escapedText}`;
+ // Remove target="_blank" for internal navigation
+ return `@${escapedText}`;
}
/**
@@ -167,9 +168,9 @@ export async function createProfileLinkWithVerification(identifier: string, disp
const type = nip05.endsWith('edu') ? 'edu' : 'standard';
switch (type) {
case 'edu':
- return `@${displayIdentifier}${graduationCapSvg}`;
+ return `@${displayIdentifier}${graduationCapSvg}`;
case 'standard':
- return `@${displayIdentifier}${badgeCheckSvg}`;
+ return `@${displayIdentifier}${badgeCheckSvg}`;
}
}
/**
diff --git a/src/routes/about/+page.svelte b/src/routes/about/+page.svelte
index a6badf3..b5b7c09 100644
--- a/src/routes/about/+page.svelte
+++ b/src/routes/about/+page.svelte
@@ -1,6 +1,7 @@
diff --git a/src/routes/start/+page.svelte b/src/routes/start/+page.svelte
index 05d0776..04177de 100644
--- a/src/routes/start/+page.svelte
+++ b/src/routes/start/+page.svelte
@@ -1,5 +1,6 @@