rm /e/ and /p/ from event & profile links

This commit is contained in:
Martti Malmi 2023-10-17 11:57:47 +03:00
parent 089c40d816
commit ca18cf25e3
5 changed files with 17 additions and 7 deletions

View File

@ -13,7 +13,7 @@ export default function NostrLink({ link, depth }: { link: string; depth?: numbe
if ((depth ?? 0) > 0) { if ((depth ?? 0) > 0) {
const evLink = nav.encode(); const evLink = nav.encode();
return ( return (
<Link to={`/e/${evLink}`} onClick={e => e.stopPropagation()} state={{ from: location.pathname }}> <Link to={`/${evLink}`} onClick={e => e.stopPropagation()} state={{ from: location.pathname }}>
#{evLink.substring(0, 12)} #{evLink.substring(0, 12)}
</Link> </Link>
); );

View File

@ -154,9 +154,9 @@ export function NoteInner(props: NoteProps) {
const link = NostrLink.fromEvent(eTarget); const link = NostrLink.fromEvent(eTarget);
// detect cmd key and open in new tab // detect cmd key and open in new tab
if (e.metaKey) { if (e.metaKey) {
window.open(`/e/${link.encode()}`, "_blank"); window.open(`/${link.encode()}`, "_blank");
} else { } else {
navigate(`/e/${link.encode()}`, { navigate(`/${link.encode()}`, {
state: eTarget, state: eTarget,
}); });
} }
@ -211,7 +211,7 @@ export function NoteInner(props: NoteProps) {
{pubMentions} {others} {pubMentions} {others}
</> </>
) : ( ) : (
replyLink && <Link to={`/e/${replyLink.encode()}`}>{replyLink.encode().substring(0, 12)}</Link> replyLink && <Link to={`/${replyLink.encode()}`}>{replyLink.encode().substring(0, 12)}</Link>
)} )}
</div> </div>
); );

View File

@ -238,7 +238,7 @@ export function Thread(props: { onBack?: () => void; disableSpotlight?: boolean
function navigateThread(e: TaggedNostrEvent) { function navigateThread(e: TaggedNostrEvent) {
thread.setCurrent(e.id); thread.setCurrent(e.id);
//router.navigate(`/e/${NostrLink.fromEvent(e).encode()}`, { replace: true }) //router.navigate(`/${NostrLink.fromEvent(e).encode()}`, { replace: true })
} }
const parent = useMemo(() => { const parent = useMemo(() => {

View File

@ -395,7 +395,7 @@ function NotificationGroup({ evs, onClick }: { evs: Array<TaggedNostrEvent>; onC
if (onClick) { if (onClick) {
onClick(context); onClick(context);
} else { } else {
navigate(`/e/${context.encode()}`); navigate(`/${context.encode()}`);
} }
}} }}
/> />

View File

@ -107,7 +107,17 @@ export function eventLink(hex: u256, relays?: Array<string> | string) {
const encoded = relays const encoded = relays
? encodeTLV(NostrPrefix.Event, hex, Array.isArray(relays) ? relays : [relays]) ? encodeTLV(NostrPrefix.Event, hex, Array.isArray(relays) ? relays : [relays])
: hexToBech32(NostrPrefix.Note, hex); : hexToBech32(NostrPrefix.Note, hex);
return `/e/${encoded}`; return `/${encoded}`;
}
/**
* Convert hex pubkey to bech32 link url
*/
export function profileLink(hex: HexKey, relays?: Array<string> | string) {
const encoded = relays
? encodeTLV(NostrPrefix.Profile, hex, Array.isArray(relays) ? relays : [relays])
: hexToBech32(NostrPrefix.PublicKey, hex);
return `/${encoded}`;
} }
/** /**